Do not reference bitmap color spaces directly anymore, but use
bitmaps_support_space() interface kit function. First try to use overlays, if that fails, try again without overlays. The NodeManager makes sure to fall back to B_RGB32 if the given mode is not supported for drawing bitmaps in by BViews. Thanks, Axel, for the suggestion! git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@25764 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -358,15 +358,29 @@ NodeManager::_SetUpVideoNodes(color_space preferredVideoFormat)
|
|||||||
};
|
};
|
||||||
format.u.raw_video = videoFormat;
|
format.u.raw_video = videoFormat;
|
||||||
|
|
||||||
// connect video producer to consumer (B_YCbCr422)
|
// connect video producer to consumer (hopefully using overlays)
|
||||||
|
fVideoConsumer->SetTryOverlay(true);
|
||||||
fStatus = fMediaRoster->Connect(videoOutput.source, videoInput.destination,
|
fStatus = fMediaRoster->Connect(videoOutput.source, videoInput.destination,
|
||||||
&format, &videoOutput, &videoInput);
|
&format, &videoOutput, &videoInput);
|
||||||
|
|
||||||
if (fStatus != B_OK && preferredVideoFormat != B_RGB32) {
|
if (fStatus != B_OK) {
|
||||||
print_error("Can't connect the video source to the video window... "
|
print_error("Can't connect the video source to the video window... "
|
||||||
"trying B_RGB32", fStatus);
|
"trying without overlays", fStatus);
|
||||||
|
|
||||||
|
uint32 flags = 0;
|
||||||
|
bool supported = bitmaps_support_space(
|
||||||
|
format.u.raw_video.display.format, &flags);
|
||||||
|
if (!supported || (flags & B_VIEWS_SUPPORT_DRAW_BITMAP) == 0) {
|
||||||
|
// cannot create bitmaps with such a color space
|
||||||
|
// or BViews don't support drawing it, fallback to B_RGB32
|
||||||
format.u.raw_video.display.format = B_RGB32;
|
format.u.raw_video.display.format = B_RGB32;
|
||||||
// connect video producer to consumer (B_RGB32)
|
printf("NodeManager::_SetupVideoNodes() - falling back to "
|
||||||
|
"B_RGB32\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
fVideoConsumer->SetTryOverlay(false);
|
||||||
|
// connect video producer to consumer (not using overlays and using
|
||||||
|
// a colorspace that BViews support drawing)
|
||||||
fStatus = fMediaRoster->Connect(videoOutput.source,
|
fStatus = fMediaRoster->Connect(videoOutput.source,
|
||||||
videoInput.destination, &format, &videoOutput, &videoInput);
|
videoInput.destination, &format, &videoOutput, &videoInput);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,20 +7,19 @@
|
|||||||
*/
|
*/
|
||||||
#include "VideoConsumer.h"
|
#include "VideoConsumer.h"
|
||||||
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
#include <Buffer.h>
|
#include <stdio.h>
|
||||||
#include <unistd.h>
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
|
||||||
|
#include <Buffer.h>
|
||||||
|
#include <BufferGroup.h>
|
||||||
#include <NodeInfo.h>
|
#include <NodeInfo.h>
|
||||||
#include <Application.h>
|
|
||||||
#include <Bitmap.h>
|
#include <Bitmap.h>
|
||||||
#include <View.h>
|
#include <View.h>
|
||||||
#include <Window.h>
|
|
||||||
#include <scheduler.h>
|
#include <scheduler.h>
|
||||||
#include <TimeSource.h>
|
#include <TimeSource.h>
|
||||||
#include <MediaRoster.h>
|
#include <MediaRoster.h>
|
||||||
#include <BufferGroup.h>
|
|
||||||
|
|
||||||
#include "NodeManager.h"
|
#include "NodeManager.h"
|
||||||
#include "VideoTarget.h"
|
#include "VideoTarget.h"
|
||||||
@@ -61,7 +60,8 @@ VideoConsumer::VideoConsumer(const char* name, BMediaAddOn* addon,
|
|||||||
fManager(manager),
|
fManager(manager),
|
||||||
fTargetLock(),
|
fTargetLock(),
|
||||||
fTarget(target),
|
fTarget(target),
|
||||||
fTargetBufferIndex(-1)
|
fTargetBufferIndex(-1),
|
||||||
|
fTryOverlay(true)
|
||||||
{
|
{
|
||||||
FUNCTION("VideoConsumer::VideoConsumer\n");
|
FUNCTION("VideoConsumer::VideoConsumer\n");
|
||||||
|
|
||||||
@@ -225,8 +225,7 @@ VideoConsumer::CreateBuffers(const media_format& format)
|
|||||||
for (uint32 i = 0; i < kBufferCount; i++) {
|
for (uint32 i = 0; i < kBufferCount; i++) {
|
||||||
// figure out the bitmap creation flags
|
// figure out the bitmap creation flags
|
||||||
uint32 bitmapFlags = 0;
|
uint32 bitmapFlags = 0;
|
||||||
if (colorSpace == B_YCbCr420 || colorSpace == B_YCbCr411
|
if (fTryOverlay) {
|
||||||
|| colorSpace == B_YCbCr422 || colorSpace == B_YCbCr444) {
|
|
||||||
// try to use hardware overlay
|
// try to use hardware overlay
|
||||||
bitmapFlags |= B_BITMAP_WILL_OVERLAY;
|
bitmapFlags |= B_BITMAP_WILL_OVERLAY;
|
||||||
if (i == 0)
|
if (i == 0)
|
||||||
@@ -338,6 +337,13 @@ VideoConsumer::SetTarget(VideoTarget* target)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
VideoConsumer::SetTryOverlay(bool tryOverlay)
|
||||||
|
{
|
||||||
|
fTryOverlay = tryOverlay;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
status_t
|
status_t
|
||||||
VideoConsumer::Connected(const media_source& producer,
|
VideoConsumer::Connected(const media_source& producer,
|
||||||
const media_destination& where, const media_format& format,
|
const media_destination& where, const media_format& format,
|
||||||
@@ -429,22 +435,30 @@ VideoConsumer::AcceptFormat(const media_destination& dest, media_format* format)
|
|||||||
return B_MEDIA_BAD_FORMAT;
|
return B_MEDIA_BAD_FORMAT;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (format->u.raw_video.display.format != B_YCbCr444 &&
|
if (format->u.raw_video.display.format
|
||||||
format->u.raw_video.display.format != B_YCbCr422 &&
|
|
||||||
format->u.raw_video.display.format != B_RGB32 &&
|
|
||||||
format->u.raw_video.display.format != B_RGB16 &&
|
|
||||||
format->u.raw_video.display.format != B_RGB15 &&
|
|
||||||
format->u.raw_video.display.format != B_GRAY8 &&
|
|
||||||
format->u.raw_video.display.format
|
|
||||||
!= media_raw_video_format::wildcard.display.format) {
|
!= media_raw_video_format::wildcard.display.format) {
|
||||||
ERROR("AcceptFormat - not a format we know about!\n");
|
uint32 flags = 0;
|
||||||
|
bool supported = bitmaps_support_space(
|
||||||
|
format->u.raw_video.display.format, &flags);
|
||||||
|
if (!supported) {
|
||||||
|
// cannot create bitmaps with such a color space
|
||||||
|
ERROR("AcceptFormat - unsupported color space for BBitmaps!\n");
|
||||||
return B_MEDIA_BAD_FORMAT;
|
return B_MEDIA_BAD_FORMAT;
|
||||||
}
|
}
|
||||||
|
if (!fTryOverlay && (flags & B_VIEWS_SUPPORT_DRAW_BITMAP) == 0) {
|
||||||
|
// BViews do not support drawing such a bitmap
|
||||||
|
ERROR("AcceptFormat - BViews cannot draw bitmaps in given "
|
||||||
|
"colorspace!\n");
|
||||||
|
return B_MEDIA_BAD_FORMAT;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef TRACE_VIDEO_CONSUMER
|
||||||
char string[256];
|
char string[256];
|
||||||
string[0] = 0;
|
string[0] = 0;
|
||||||
string_for_format(*format, string, 256);
|
string_for_format(*format, string, 256);
|
||||||
FUNCTION("VideoConsumer::AcceptFormat: %s\n", string);
|
FUNCTION("VideoConsumer::AcceptFormat: %s\n", string);
|
||||||
|
#endif
|
||||||
|
|
||||||
return B_OK;
|
return B_OK;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -100,6 +100,7 @@ public:
|
|||||||
void DeleteBuffers();
|
void DeleteBuffers();
|
||||||
|
|
||||||
void SetTarget(VideoTarget* target);
|
void SetTarget(VideoTarget* target);
|
||||||
|
void SetTryOverlay(bool tryOverlay);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
uint32 fInternalID;
|
uint32 fInternalID;
|
||||||
@@ -119,6 +120,8 @@ public:
|
|||||||
BLocker fTargetLock; // locks the following variable
|
BLocker fTargetLock; // locks the following variable
|
||||||
VideoTarget* volatile fTarget;
|
VideoTarget* volatile fTarget;
|
||||||
int32 fTargetBufferIndex;
|
int32 fTargetBufferIndex;
|
||||||
|
|
||||||
|
bool fTryOverlay;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // VIDEO_CONSUMER_H
|
#endif // VIDEO_CONSUMER_H
|
||||||
|
|||||||
Reference in New Issue
Block a user