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:
parent
50c7a8f997
commit
12f1188b4f
@ -358,15 +358,29 @@ NodeManager::_SetUpVideoNodes(color_space preferredVideoFormat)
|
||||
};
|
||||
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,
|
||||
&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... "
|
||||
"trying B_RGB32", fStatus);
|
||||
format.u.raw_video.display.format = B_RGB32;
|
||||
// connect video producer to consumer (B_RGB32)
|
||||
"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;
|
||||
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,
|
||||
videoInput.destination, &format, &videoOutput, &videoInput);
|
||||
}
|
||||
|
@ -7,20 +7,19 @@
|
||||
*/
|
||||
#include "VideoConsumer.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <fcntl.h>
|
||||
#include <Buffer.h>
|
||||
#include <unistd.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include <Buffer.h>
|
||||
#include <BufferGroup.h>
|
||||
#include <NodeInfo.h>
|
||||
#include <Application.h>
|
||||
#include <Bitmap.h>
|
||||
#include <View.h>
|
||||
#include <Window.h>
|
||||
#include <scheduler.h>
|
||||
#include <TimeSource.h>
|
||||
#include <MediaRoster.h>
|
||||
#include <BufferGroup.h>
|
||||
|
||||
#include "NodeManager.h"
|
||||
#include "VideoTarget.h"
|
||||
@ -61,7 +60,8 @@ VideoConsumer::VideoConsumer(const char* name, BMediaAddOn* addon,
|
||||
fManager(manager),
|
||||
fTargetLock(),
|
||||
fTarget(target),
|
||||
fTargetBufferIndex(-1)
|
||||
fTargetBufferIndex(-1),
|
||||
fTryOverlay(true)
|
||||
{
|
||||
FUNCTION("VideoConsumer::VideoConsumer\n");
|
||||
|
||||
@ -219,14 +219,13 @@ VideoConsumer::CreateBuffers(const media_format& format)
|
||||
ERROR("VideoConsumer::CreateBuffers - ERROR CREATING BUFFER GROUP\n");
|
||||
return status;
|
||||
}
|
||||
|
||||
|
||||
// and attach the bitmaps to the buffer group
|
||||
BRect bounds(0, 0, width - 1, height - 1);
|
||||
for (uint32 i = 0; i < kBufferCount; i++) {
|
||||
// figure out the bitmap creation flags
|
||||
uint32 bitmapFlags = 0;
|
||||
if (colorSpace == B_YCbCr420 || colorSpace == B_YCbCr411
|
||||
|| colorSpace == B_YCbCr422 || colorSpace == B_YCbCr444) {
|
||||
if (fTryOverlay) {
|
||||
// try to use hardware overlay
|
||||
bitmapFlags |= B_BITMAP_WILL_OVERLAY;
|
||||
if (i == 0)
|
||||
@ -338,6 +337,13 @@ VideoConsumer::SetTarget(VideoTarget* target)
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
VideoConsumer::SetTryOverlay(bool tryOverlay)
|
||||
{
|
||||
fTryOverlay = tryOverlay;
|
||||
}
|
||||
|
||||
|
||||
status_t
|
||||
VideoConsumer::Connected(const media_source& producer,
|
||||
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;
|
||||
}
|
||||
|
||||
if (format->u.raw_video.display.format != B_YCbCr444 &&
|
||||
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
|
||||
if (format->u.raw_video.display.format
|
||||
!= media_raw_video_format::wildcard.display.format) {
|
||||
ERROR("AcceptFormat - not a format we know about!\n");
|
||||
return B_MEDIA_BAD_FORMAT;
|
||||
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;
|
||||
}
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
char string[256];
|
||||
string[0] = 0;
|
||||
string_for_format(*format, string, 256);
|
||||
FUNCTION("VideoConsumer::AcceptFormat: %s\n", string);
|
||||
|
||||
#ifdef TRACE_VIDEO_CONSUMER
|
||||
char string[256];
|
||||
string[0] = 0;
|
||||
string_for_format(*format, string, 256);
|
||||
FUNCTION("VideoConsumer::AcceptFormat: %s\n", string);
|
||||
#endif
|
||||
|
||||
return B_OK;
|
||||
}
|
||||
|
@ -100,7 +100,8 @@ public:
|
||||
void DeleteBuffers();
|
||||
|
||||
void SetTarget(VideoTarget* target);
|
||||
|
||||
void SetTryOverlay(bool tryOverlay);
|
||||
|
||||
private:
|
||||
uint32 fInternalID;
|
||||
BMediaAddOn* fAddOn;
|
||||
@ -119,6 +120,8 @@ public:
|
||||
BLocker fTargetLock; // locks the following variable
|
||||
VideoTarget* volatile fTarget;
|
||||
int32 fTargetBufferIndex;
|
||||
|
||||
bool fTryOverlay;
|
||||
};
|
||||
|
||||
#endif // VIDEO_CONSUMER_H
|
||||
|
Loading…
x
Reference in New Issue
Block a user