* Patch by Jorma Karvonnen : localize TV application and style fixes. Thanks !

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@37303 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Adrien Destugues
2010-06-29 17:22:17 +00:00
parent de1057eeb1
commit 8130a01dbe
9 changed files with 388 additions and 172 deletions
+2 -1
View File
@@ -37,7 +37,8 @@ ConvertBitmap(BBitmap *dst, const BBitmap *src)
if (dst->Bounds() != src->Bounds())
return B_BAD_VALUE;
if (dst->ColorSpace() == src->ColorSpace() && dst->BytesPerRow() == src->BytesPerRow() ) {
if (dst->ColorSpace() == src->ColorSpace()
&& dst->BytesPerRow() == src->BytesPerRow() ) {
memcpy(dst->Bits(), src->Bits(), src->BitsLength());
return B_OK;
}
+12 -6
View File
@@ -38,9 +38,11 @@ DeviceRoster::DeviceRoster()
live_node_info info[MAX_DEVICE_COUNT];
int32 info_count = MAX_DEVICE_COUNT;
status_t err;
err = MediaRoster()->GetLiveNodes(info, &info_count, NULL, NULL, "DVB*", B_BUFFER_PRODUCER | B_PHYSICAL_INPUT);
err = MediaRoster()->GetLiveNodes(info, &info_count, NULL, NULL, "DVB*",
B_BUFFER_PRODUCER | B_PHYSICAL_INPUT);
if (err != B_OK || info_count < 1) {
printf("Can't find live DVB node. Found %ld nodes, error %08lx (%s)\n", info_count, err, strerror(err));
printf("Can't find live DVB node. Found %ld nodes, error %08lx (%s)\n",
info_count, err, strerror(err));
fDeviceCount = 0;
} else {
fDeviceCount = info_count;
@@ -89,7 +91,8 @@ DeviceRoster::IsRawAudioOutputFree(int i)
int32 count;
status_t err;
err = MediaRoster()->GetFreeOutputsFor(fDeviceInfo[i].node, &output, 1, &count, B_MEDIA_RAW_AUDIO);
err = MediaRoster()->GetFreeOutputsFor(fDeviceInfo[i].node, &output, 1,
&count, B_MEDIA_RAW_AUDIO);
return (err == B_OK) && (count == 1);
}
@@ -103,7 +106,8 @@ DeviceRoster::IsEncAudioOutputFree(int i)
int32 count;
status_t err;
err = MediaRoster()->GetFreeOutputsFor(fDeviceInfo[i].node, &output, 1, &count, B_MEDIA_ENCODED_AUDIO);
err = MediaRoster()->GetFreeOutputsFor(fDeviceInfo[i].node, &output, 1,
&count, B_MEDIA_ENCODED_AUDIO);
return (err == B_OK) && (count == 1);
}
@@ -117,7 +121,8 @@ DeviceRoster::IsRawVideoOutputFree(int i)
int32 count;
status_t err;
err = MediaRoster()->GetFreeOutputsFor(fDeviceInfo[i].node, &output, 1, &count, B_MEDIA_RAW_VIDEO);
err = MediaRoster()->GetFreeOutputsFor(fDeviceInfo[i].node, &output, 1,
&count, B_MEDIA_RAW_VIDEO);
return (err == B_OK) && (count == 1);
}
@@ -131,7 +136,8 @@ DeviceRoster::IsEncVideoOutputFree(int i)
int32 count;
status_t err;
err = MediaRoster()->GetFreeOutputsFor(fDeviceInfo[i].node, &output, 1, &count, B_MEDIA_ENCODED_VIDEO);
err = MediaRoster()->GetFreeOutputsFor(fDeviceInfo[i].node, &output, 1,
&count, B_MEDIA_ENCODED_VIDEO);
return (err == B_OK) && (count == 1);
}
+8 -1
View File
@@ -8,6 +8,13 @@ Application TV :
MainWin.cpp
VideoNode.cpp
VideoView.cpp
: be media $(TARGET_LIBSUPC++)
: be locale media $(TARGET_LIBSUPC++)
: tv.rdef
;
DoCatalogs TV :
x-vnd.Haiku.TV
:
MainApp.cpp
MainWin.cpp
;
+8 -1
View File
@@ -33,15 +33,22 @@
#include "config.h"
#include "DeviceRoster.h"
#undef B_TRANSLATE_CONTEXT
#define B_TRANSLATE_CONTEXT "MainApp"
MainApp *gMainApp;
bool gOverlayDisabled = false;
MainApp::MainApp()
: BApplication(APP_SIG)
:
BApplication(APP_SIG)
{
InitPrefs();
be_locale->GetAppCatalog(&fAppCatalog);
gDeviceRoster = new DeviceRoster;
fMainWindow = NewWindow();
+1
View File
@@ -38,6 +38,7 @@ public:
private:
BWindow * fMainWindow;
BCatalog fAppCatalog;
};
extern MainApp *gMainApp;
+261 -118
View File
@@ -28,18 +28,27 @@
#include "config.h"
#include "DeviceRoster.h"
#include <View.h>
#include <Screen.h>
#include <stdio.h>
#include <string.h>
#include <Application.h>
#include <Alert.h>
#include <Menu.h>
#include <MenuBar.h>
#include <MenuItem.h>
#include <Application.h>
#include <Alert.h>
#include <stdio.h>
#include <string.h>
#include <Messenger.h>
#include <PopUpMenu.h>
#include <Screen.h>
#include <String.h>
#include <View.h>
#undef B_TRANSLATE_CONTEXT
#define B_TRANSLATE_CONTEXT "MainWin"
static const char* fLocalizedName = B_TRANSLATE_MARK("TV");
static const char* fLocalizedRevision = B_TRANSLATE_MARK("unknown");
static const char* fLocalizedInfo1 = B_TRANSLATE_MARK("DVB - Digital Video Broadcasting TV");
enum
{
@@ -68,14 +77,16 @@ enum
M_SELECT_INTERFACE = 0x00000800,
M_SELECT_INTERFACE_END = 0x00000fff,
M_SELECT_CHANNEL = 0x00010000,
M_SELECT_CHANNEL_END = 0x000fffff, // this limits possible channel count to 0xeffff = 983039
M_SELECT_CHANNEL_END = 0x000fffff,
// this limits possible channel count to 0xeffff = 983039
};
//#define printf(a...)
MainWin::MainWin(BRect frame_rect)
: BWindow(frame_rect, NAME, B_TITLED_WINDOW, B_ASYNCHRONOUS_CONTROLS /* | B_WILL_ACCEPT_FIRST_CLICK */)
: BWindow(frame_rect, NAME, B_TITLED_WINDOW,
B_ASYNCHRONOUS_CONTROLS /* | B_WILL_ACCEPT_FIRST_CLICK */)
, fController(new Controller)
, fIsFullscreen(false)
, fKeepAspectRatio(true)
@@ -92,9 +103,10 @@ MainWin::MainWin(BRect frame_rect)
, fFrameResizedCalled(true)
{
BRect rect = Bounds();
// background
fBackground = new BView(rect, "background", B_FOLLOW_ALL, B_WILL_DRAW | B_FULL_UPDATE_ON_RESIZE);
fBackground = new BView(rect, "background", B_FOLLOW_ALL,
B_WILL_DRAW | B_FULL_UPDATE_ON_RESIZE);
fBackground->SetViewColor(0,0,0);
AddChild(fBackground);
@@ -108,13 +120,15 @@ MainWin::MainWin(BRect frame_rect)
// video view
BRect video_rect = BRect(0, fMenuBarHeight, rect.right, rect.bottom);
fVideoView = new VideoView(video_rect, "video display", B_FOLLOW_ALL, B_WILL_DRAW | B_FULL_UPDATE_ON_RESIZE);
fVideoView = new VideoView(video_rect, "video display", B_FOLLOW_ALL,
B_WILL_DRAW | B_FULL_UPDATE_ON_RESIZE);
fBackground->AddChild(fVideoView);
fVideoView->MakeFocus();
// SetSizeLimits(fControlViewMinWidth - 1, 32767,
// fMenuBarHeight + fControlViewHeight - 1, fMenuBarHeight + fControlViewHeight - 1);
// fMenuBarHeight + fControlViewHeight - 1, fMenuBarHeight
// + fControlViewHeight - 1);
// SetSizeLimits(320 - 1, 32767, 240 + fMenuBarHeight - 1, 32767);
@@ -149,10 +163,10 @@ void
MainWin::CreateMenu()
{
fFileMenu = new BMenu(NAME);
fChannelMenu = new BMenu("Channel");
fInterfaceMenu = new BMenu("Interface");
fSettingsMenu = new BMenu("Settings");
fDebugMenu = new BMenu("Debug");
fChannelMenu = new BMenu(B_TRANSLATE("Channel"));
fInterfaceMenu = new BMenu(B_TRANSLATE("Interface"));
fSettingsMenu = new BMenu(B_TRANSLATE("Settings"));
fDebugMenu = new BMenu(B_TRANSLATE("Debug"));
fMenuBar->AddItem(fFileMenu);
fMenuBar->AddItem(fChannelMenu);
@@ -160,46 +174,85 @@ MainWin::CreateMenu()
fMenuBar->AddItem(fSettingsMenu);
fMenuBar->AddItem(fDebugMenu);
fFileMenu->AddItem(new BMenuItem("About " NAME B_UTF8_ELLIPSIS, new BMessage(M_FILE_ABOUT)));
BString aboutStr = B_TRANSLATE_COMMENT("About %1"B_UTF8_ELLIPSIS,
"Parameter %1 is the name of the application.");
aboutStr.ReplaceFirst("%1", fLocalizedName);
fFileMenu->AddItem(new BMenuItem(aboutStr.String(),
new BMessage(M_FILE_ABOUT)));
fFileMenu->AddSeparatorItem();
fFileMenu->AddItem(new BMenuItem("Quit", new BMessage(M_FILE_QUIT), 'Q', B_COMMAND_KEY));
fFileMenu->AddItem(new BMenuItem(B_TRANSLATE("Quit"),
new BMessage(M_FILE_QUIT), 'Q', B_COMMAND_KEY));
/*
fChannelMenu->AddItem(new BMenuItem("Next channel", new BMessage(M_CHANNEL_NEXT), '+', B_COMMAND_KEY));
fChannelMenu->AddItem(new BMenuItem("Previous channel", new BMessage(M_CHANNEL_PREV), '-', B_COMMAND_KEY));
fChannelMenu->AddItem(new BMenuItem(B_TRANSLATE("Next channel"),
new BMessage(M_CHANNEL_NEXT), '+', B_COMMAND_KEY));
fChannelMenu->AddItem(new BMenuItem(B_TRANSLATE("Previous channel"),
new BMessage(M_CHANNEL_PREV), '-', B_COMMAND_KEY));
fChannelMenu->AddSeparatorItem();
fChannelMenu->AddItem(new BMenuItem("RTL", new BMessage(M_DUMMY), '0', B_COMMAND_KEY));
fChannelMenu->AddItem(new BMenuItem("Pro7", new BMessage(M_DUMMY), '1', B_COMMAND_KEY));
fChannelMenu->AddItem(new BMenuItem("RTL", new BMessage(M_DUMMY), '0',
B_COMMAND_KEY));
fChannelMenu->AddItem(new BMenuItem("Pro7", new BMessage(M_DUMMY), '1',
B_COMMAND_KEY));
fInterfaceMenu->AddItem(new BMenuItem("none", new BMessage(M_DUMMY)));
fInterfaceMenu->AddItem(new BMenuItem("none 1", new BMessage(M_DUMMY)));
fInterfaceMenu->AddItem(new BMenuItem("none 2", new BMessage(M_DUMMY)));
fInterfaceMenu->AddItem(new BMenuItem(B_TRANSLATE("none"),
new BMessage(M_DUMMY)));
fInterfaceMenu->AddItem(new BMenuItem(B_TRANSLATE("none 1"),
new BMessage(M_DUMMY)));
fInterfaceMenu->AddItem(new BMenuItem(B_TRANSLATE("none 2"),
new BMessage(M_DUMMY)));
*/
fSettingsMenu->AddItem(new BMenuItem("Scale to native size", new BMessage(M_SCALE_TO_NATIVE_SIZE), 'N', B_COMMAND_KEY));
fSettingsMenu->AddItem(new BMenuItem("Full screen", new BMessage(M_TOGGLE_FULLSCREEN), 'F', B_COMMAND_KEY));
fSettingsMenu->AddItem(new BMenuItem(B_TRANSLATE("Scale to native size"),
new BMessage(M_SCALE_TO_NATIVE_SIZE), 'N', B_COMMAND_KEY));
fSettingsMenu->AddItem(new BMenuItem(B_TRANSLATE("Full screen"),
new BMessage(M_TOGGLE_FULLSCREEN), 'F', B_COMMAND_KEY));
fSettingsMenu->AddSeparatorItem();
fSettingsMenu->AddItem(new BMenuItem("No menu", new BMessage(M_TOGGLE_NO_MENU), 'M', B_COMMAND_KEY));
fSettingsMenu->AddItem(new BMenuItem("No border", new BMessage(M_TOGGLE_NO_BORDER), 'B', B_COMMAND_KEY));
fSettingsMenu->AddItem(new BMenuItem("Always on top", new BMessage(M_TOGGLE_ALWAYS_ON_TOP), 'T', B_COMMAND_KEY));
fSettingsMenu->AddItem(new BMenuItem("Keep aspect ratio", new BMessage(M_TOGGLE_KEEP_ASPECT_RATIO), 'K', B_COMMAND_KEY));
fSettingsMenu->AddItem(new BMenuItem(B_TRANSLATE("No menu"),
new BMessage(M_TOGGLE_NO_MENU), 'M', B_COMMAND_KEY));
fSettingsMenu->AddItem(new BMenuItem(B_TRANSLATE("No border"),
new BMessage(M_TOGGLE_NO_BORDER), 'B', B_COMMAND_KEY));
fSettingsMenu->AddItem(new BMenuItem(B_TRANSLATE("Always on top"),
new BMessage(M_TOGGLE_ALWAYS_ON_TOP), 'T', B_COMMAND_KEY));
fSettingsMenu->AddItem(new BMenuItem(B_TRANSLATE("Keep aspect ratio"),
new BMessage(M_TOGGLE_KEEP_ASPECT_RATIO), 'K', B_COMMAND_KEY));
fSettingsMenu->AddSeparatorItem();
fSettingsMenu->AddItem(new BMenuItem("Settings"B_UTF8_ELLIPSIS, new BMessage(M_PREFERENCES), 'P', B_COMMAND_KEY));
fSettingsMenu->AddItem(new BMenuItem(B_TRANSLATE("Settings"B_UTF8_ELLIPSIS)
, new BMessage(M_PREFERENCES), 'P', B_COMMAND_KEY));
fDebugMenu->AddItem(new BMenuItem("pixel aspect ratio 1.00000:1", new BMessage(M_ASPECT_100000_1)));
fDebugMenu->AddItem(new BMenuItem("pixel aspect ratio 1.06666:1", new BMessage(M_ASPECT_106666_1)));
fDebugMenu->AddItem(new BMenuItem("pixel aspect ratio 1.09091:1", new BMessage(M_ASPECT_109091_1)));
fDebugMenu->AddItem(new BMenuItem("pixel aspect ratio 1.41176:1", new BMessage(M_ASPECT_141176_1)));
fDebugMenu->AddItem(new BMenuItem("force 720 x 576, display aspect 4:3", new BMessage(M_ASPECT_720_576)));
fDebugMenu->AddItem(new BMenuItem("force 704 x 576, display aspect 4:3", new BMessage(M_ASPECT_704_576)));
fDebugMenu->AddItem(new BMenuItem("force 544 x 576, display aspect 4:3", new BMessage(M_ASPECT_544_576)));
const char* pixel_ratio = B_TRANSLATE("pixel aspect ratio");
BString str1 = pixel_ratio;
str1 << " 1.00000:1";
fDebugMenu->AddItem(new BMenuItem(str1.String(),
new BMessage(M_ASPECT_100000_1)));
BString str2 = pixel_ratio;
str2 << " 1.06666:1";
fDebugMenu->AddItem(new BMenuItem(str2.String(),
new BMessage(M_ASPECT_106666_1)));
BString str3 = pixel_ratio;
str3 << " 1.09091:1";
fDebugMenu->AddItem(new BMenuItem(str3.String(),
new BMessage(M_ASPECT_109091_1)));
BString str4 = pixel_ratio;
str4 << " 1.41176:1";
fDebugMenu->AddItem(new BMenuItem(str4.String(),
new BMessage(M_ASPECT_141176_1)));
fDebugMenu->AddItem(new BMenuItem(B_TRANSLATE(
"force 720 x 576, display aspect 4:3"),
new BMessage(M_ASPECT_720_576)));
fDebugMenu->AddItem(new BMenuItem(B_TRANSLATE(
"force 704 x 576, display aspect 4:3"),
new BMessage(M_ASPECT_704_576)));
fDebugMenu->AddItem(new BMenuItem(B_TRANSLATE(
"force 544 x 576, display aspect 4:3"),
new BMessage(M_ASPECT_544_576)));
fSettingsMenu->ItemAt(1)->SetMarked(fIsFullscreen);
fSettingsMenu->ItemAt(3)->SetMarked(fNoMenu);
fSettingsMenu->ItemAt(4)->SetMarked(fNoBorder);
fSettingsMenu->ItemAt(5)->SetMarked(fAlwaysOnTop);
fSettingsMenu->ItemAt(6)->SetMarked(fKeepAspectRatio);
fSettingsMenu->ItemAt(8)->SetEnabled(false); // XXX disable unused preference menu
fSettingsMenu->ItemAt(8)->SetEnabled(false);
// XXX disable unused preference menu
}
@@ -208,7 +261,8 @@ MainWin::SetupInterfaceMenu()
{
fInterfaceMenu->RemoveItems(0, fInterfaceMenu->CountItems(), true);
fInterfaceMenu->AddItem(new BMenuItem("None", new BMessage(M_SELECT_INTERFACE)));
fInterfaceMenu->AddItem(new BMenuItem(B_TRANSLATE("None"),
new BMessage(M_SELECT_INTERFACE)));
int count = gDeviceRoster->DeviceCount();
@@ -216,8 +270,10 @@ MainWin::SetupInterfaceMenu()
fInterfaceMenu->AddSeparatorItem();
for (int i = 0; i < count; i++) {
// 1 gets subtracted in MessageReceived, so -1 is Interface None, and 0 == Interface 0 in SelectInterface()
fInterfaceMenu->AddItem(new BMenuItem(gDeviceRoster->DeviceName(i), new BMessage(M_SELECT_INTERFACE + i + 1)));
// 1 gets subtracted in MessageReceived, so -1 is Interface None,
// and 0 == Interface 0 in SelectInterface()
fInterfaceMenu->AddItem(new BMenuItem(gDeviceRoster->DeviceName(i),
new BMessage(M_SELECT_INTERFACE + i + 1)));
}
}
@@ -233,10 +289,13 @@ MainWin::SetupChannelMenu()
int channels = fController->ChannelCount();
if (channels == 0) {
fChannelMenu->AddItem(new BMenuItem("None", new BMessage(M_DUMMY)));
fChannelMenu->AddItem(new BMenuItem(B_TRANSLATE("None"),
new BMessage(M_DUMMY)));
} else {
fChannelMenu->AddItem(new BMenuItem("Next channel", new BMessage(M_CHANNEL_NEXT), '+', B_COMMAND_KEY));
fChannelMenu->AddItem(new BMenuItem("Previous channel", new BMessage(M_CHANNEL_PREV), '-', B_COMMAND_KEY));
fChannelMenu->AddItem(new BMenuItem(B_TRANSLATE("Next channel"),
new BMessage(M_CHANNEL_NEXT), '+', B_COMMAND_KEY));
fChannelMenu->AddItem(new BMenuItem(B_TRANSLATE("Previous channel"),
new BMessage(M_CHANNEL_PREV), '-', B_COMMAND_KEY));
fChannelMenu->AddSeparatorItem();
}
@@ -318,16 +377,18 @@ MainWin::SelectInterface(int i)
if (!fController->IsInterfaceAvailable(i)) {
BString s;
s << "Error, interface is busy:\n\n" << gDeviceRoster->DeviceName(i);
(new BAlert("error", s.String(), "OK"))->Go();
s << B_TRANSLATE("Error, interface is busy:\n\n");
s << gDeviceRoster->DeviceName(i);
(new BAlert("error", s.String(), B_TRANSLATE("OK")))->Go();
return;
}
fController->DisconnectInterface();
if (fController->ConnectInterface(i) != B_OK) {
BString s;
s << "Error, connecting to interface failed:\n\n" << gDeviceRoster->DeviceName(i);
(new BAlert("error", s.String(), "OK"))->Go();
s << B_TRANSLATE("Error, connecting to interface failed:\n\n");
s << gDeviceRoster->DeviceName(i);
(new BAlert("error", s.String(), B_TRANSLATE("OK")))->Go();
}
done:
@@ -348,8 +409,10 @@ MainWin::SelectInitialInterface()
int count = gDeviceRoster->DeviceCount();
for (int i = 0; i < count; i++) {
if (fController->IsInterfaceAvailable(i) && B_OK == fController->ConnectInterface(i)) {
printf("MainWin::SelectInitialInterface connected to interface %d\n", i);
if (fController->IsInterfaceAvailable(i)
&& B_OK == fController->ConnectInterface(i)) {
printf("MainWin::SelectInitialInterface connected to interface "
"%d\n", i);
break;
}
}
@@ -372,7 +435,8 @@ MainWin::MouseDown(BMessage *msg)
BPoint screen_where;
uint32 buttons = msg->FindInt32("buttons");
// On Zeta, only "screen_where" is relyable, "where" and "be:view_where" seem to be broken
// On Zeta, only "screen_where" is relyable, "where" and "be:view_where"
// seem to be broken
if (B_OK != msg->FindPoint("screen_where", &screen_where)) {
// Workaround for BeOS R5, it has no "screen_where"
fVideoView->GetMouse(&screen_where, &buttons, false);
@@ -384,7 +448,8 @@ MainWin::MouseDown(BMessage *msg)
// if (1 == msg->FindInt32("buttons") && msg->FindInt32("clicks") == 1) {
if (1 == buttons && msg->FindInt32("clicks") % 2 == 0) {
BRect r(screen_where.x - 1, screen_where.y - 1, screen_where.x + 1, screen_where.y + 1);
BRect r(screen_where.x - 1, screen_where.y - 1, screen_where.x + 1,
screen_where.y + 1);
if (r.Contains(fMouseDownMousePos)) {
PostMessage(M_TOGGLE_FULLSCREEN);
return;
@@ -392,7 +457,8 @@ MainWin::MouseDown(BMessage *msg)
}
if (2 == buttons && msg->FindInt32("clicks") % 2 == 0) {
BRect r(screen_where.x - 1, screen_where.y - 1, screen_where.x + 1, screen_where.y + 1);
BRect r(screen_where.x - 1, screen_where.y - 1, screen_where.x + 1,
screen_where.y + 1);
if (r.Contains(fMouseDownMousePos)) {
PostMessage(M_TOGGLE_NO_BORDER_NO_MENU);
return;
@@ -401,14 +467,16 @@ MainWin::MouseDown(BMessage *msg)
/*
// very broken in Zeta:
fMouseDownMousePos = fVideoView->ConvertToScreen(msg->FindPoint("where"));
fMouseDownMousePos = fVideoView->ConvertToScreen(
msg->FindPoint("where"));
*/
fMouseDownMousePos = screen_where;
fMouseDownWindowPos = Frame().LeftTop();
if (buttons == 1 && !fIsFullscreen) {
// start mouse tracking
fVideoView->SetMouseEventMask(B_POINTER_EVENTS | B_NO_POINTER_HISTORY /* | B_LOCK_WINDOW_FOCUS */);
fVideoView->SetMouseEventMask(B_POINTER_EVENTS | B_NO_POINTER_HISTORY
/* | B_LOCK_WINDOW_FOCUS */);
fMouseDownTracking = true;
}
@@ -446,7 +514,8 @@ MainWin::MouseMoved(BMessage *msg)
printf("view where: %.0f, %.0f => ", mousePos.x, mousePos.y);
fVideoView->ConvertToScreen(&mousePos);
*/
// On Zeta, only "screen_where" is relyable, "where" and "be:view_where" seem to be broken
// On Zeta, only "screen_where" is relyable, "where" and
// "be:view_where" seem to be broken
if (B_OK != msg->FindPoint("screen_where", &mousePos)) {
// Workaround for BeOS R5, it has no "screen_where"
fVideoView->GetMouse(&mousePos, &buttons, false);
@@ -477,49 +546,83 @@ MainWin::ShowContextMenu(const BPoint &screen_point)
printf("Show context menu\n");
BPopUpMenu *menu = new BPopUpMenu("context menu", false, false);
BMenuItem *item;
menu->AddItem(new BMenuItem("Scale to native size", new BMessage(M_SCALE_TO_NATIVE_SIZE), 'N', B_COMMAND_KEY));
menu->AddItem(item = new BMenuItem("Full screen", new BMessage(M_TOGGLE_FULLSCREEN), 'F', B_COMMAND_KEY));
menu->AddItem(new BMenuItem(B_TRANSLATE("Scale to native size"),
new BMessage(M_SCALE_TO_NATIVE_SIZE), 'N', B_COMMAND_KEY));
menu->AddItem(item = new BMenuItem(B_TRANSLATE("Full screen"),
new BMessage(M_TOGGLE_FULLSCREEN), 'F', B_COMMAND_KEY));
item->SetMarked(fIsFullscreen);
menu->AddSeparatorItem();
menu->AddItem(item = new BMenuItem("No menu", new BMessage(M_TOGGLE_NO_MENU), 'M', B_COMMAND_KEY));
menu->AddItem(item = new BMenuItem(B_TRANSLATE("No menu"),
new BMessage(M_TOGGLE_NO_MENU), 'M', B_COMMAND_KEY));
item->SetMarked(fNoMenu);
menu->AddItem(item = new BMenuItem("No border", new BMessage(M_TOGGLE_NO_BORDER), 'B', B_COMMAND_KEY));
menu->AddItem(item = new BMenuItem(B_TRANSLATE("No border"),
new BMessage(M_TOGGLE_NO_BORDER), 'B', B_COMMAND_KEY));
item->SetMarked(fNoBorder);
menu->AddItem(item = new BMenuItem("Always on top", new BMessage(M_TOGGLE_ALWAYS_ON_TOP), 'T', B_COMMAND_KEY));
menu->AddItem(item = new BMenuItem(B_TRANSLATE("Always on top"),
new BMessage(M_TOGGLE_ALWAYS_ON_TOP), 'T', B_COMMAND_KEY));
item->SetMarked(fAlwaysOnTop);
menu->AddItem(item = new BMenuItem("Keep aspect ratio", new BMessage(M_TOGGLE_KEEP_ASPECT_RATIO), 'K', B_COMMAND_KEY));
menu->AddItem(item = new BMenuItem(B_TRANSLATE("Keep aspect ratio"),
new BMessage(M_TOGGLE_KEEP_ASPECT_RATIO), 'K', B_COMMAND_KEY));
item->SetMarked(fKeepAspectRatio);
menu->AddSeparatorItem();
menu->AddItem(new BMenuItem("About " NAME B_UTF8_ELLIPSIS, new BMessage(M_FILE_ABOUT)));
BString aboutStr = B_TRANSLATE_COMMENT("About %1"B_UTF8_ELLIPSIS,
"Parameter %1 is the name of the application.");
aboutStr.ReplaceFirst("%1", fLocalizedName);
menu->AddItem(new BMenuItem(aboutStr.String(),
new BMessage(M_FILE_ABOUT)));
menu->AddSeparatorItem();
menu->AddItem(new BMenuItem("Quit", new BMessage(M_FILE_QUIT), 'Q', B_COMMAND_KEY));
menu->AddItem(new BMenuItem(B_TRANSLATE("Quit"),
new BMessage(M_FILE_QUIT), 'Q', B_COMMAND_KEY));
menu->AddSeparatorItem();
menu->AddItem(new BMenuItem("pixel aspect ratio 1.00000:1", new BMessage(M_ASPECT_100000_1)));
menu->AddItem(new BMenuItem("pixel aspect ratio 1.06666:1", new BMessage(M_ASPECT_106666_1)));
menu->AddItem(new BMenuItem("pixel aspect ratio 1.09091:1", new BMessage(M_ASPECT_109091_1)));
menu->AddItem(new BMenuItem("pixel aspect ratio 1.41176:1", new BMessage(M_ASPECT_141176_1)));
menu->AddItem(new BMenuItem("force 720 x 576, display aspect 4:3", new BMessage(M_ASPECT_720_576)));
menu->AddItem(new BMenuItem("force 704 x 576, display aspect 4:3", new BMessage(M_ASPECT_704_576)));
menu->AddItem(new BMenuItem("force 544 x 576, display aspect 4:3", new BMessage(M_ASPECT_544_576)));
const char* pixel_aspect = "pixel aspect ratio";
BString str1 = pixel_aspect;
str1 << " 1.00000:1";
menu->AddItem(new BMenuItem(str1.String(),
new BMessage(M_ASPECT_100000_1)));
BString str2 = pixel_aspect;
str2 << " 1.06666:1";
menu->AddItem(new BMenuItem(str2.String(),
new BMessage(M_ASPECT_106666_1)));
BString str3 = pixel_aspect;
str3 << " 1.09091:1";
menu->AddItem(new BMenuItem(str3.String(),
new BMessage(M_ASPECT_109091_1)));
BString str4 = pixel_aspect;
str4 << " 1.41176:1";
menu->AddItem(new BMenuItem(str4.String(),
new BMessage(M_ASPECT_141176_1)));
menu->AddItem(new BMenuItem(B_TRANSLATE(
"force 720 x 576, display aspect 4:3"),
new BMessage(M_ASPECT_720_576)));
menu->AddItem(new BMenuItem(B_TRANSLATE(
"force 704 x 576, display aspect 4:3"),
new BMessage(M_ASPECT_704_576)));
menu->AddItem(new BMenuItem(B_TRANSLATE(
"force 544 x 576, display aspect 4:3"),
new BMessage(M_ASPECT_544_576)));
menu->SetTargetForItems(this);
BRect r(screen_point.x - 5, screen_point.y - 5, screen_point.x + 5, screen_point.y + 5);
BRect r(screen_point.x - 5, screen_point.y - 5, screen_point.x + 5,
screen_point.y + 5);
menu->Go(screen_point, true, true, r, true);
}
void
MainWin::VideoFormatChange(int width, int height, float width_scale, float height_scale)
MainWin::VideoFormatChange(int width, int height, float width_scale,
float height_scale)
{
// called when video format or aspect ratio changes
printf("VideoFormatChange enter: width %d, height %d, width_scale %.6f, height_scale %.6f\n", width, height, width_scale, height_scale);
printf("VideoFormatChange enter: width %d, height %d, width_scale %.6f, "
"height_scale %.6f\n", width, height, width_scale, height_scale);
if (width_scale < 1.0 && height_scale >= 1.0) {
width_scale = 1.0 / width_scale;
height_scale = 1.0 / height_scale;
printf("inverting! new values: width_scale %.6f, height_scale %.6f\n", width_scale, height_scale);
printf("inverting! new values: width_scale %.6f, height_scale %.6f\n",
width_scale, height_scale);
}
fSourceWidth = width;
@@ -558,7 +661,9 @@ MainWin::FrameResized(float new_width, float new_height)
}
printf("FrameResized enter: new_width %.0f, new_height %.0f, bounds width %.0f, bounds height %.0f\n", new_width, new_height, Bounds().Width(), Bounds().Height());
printf("FrameResized enter: new_width %.0f, new_height %.0f, bounds width "
"%.0f, bounds height %.0f\n", new_width, new_height, Bounds().Width(),
Bounds().Height());
if (fIsFullscreen) {
@@ -599,7 +704,9 @@ void
MainWin::UpdateWindowTitle()
{
char buf[100];
sprintf(buf, "%s - %d x %d, %.3f:%.3f => %.0f x %.0f", NAME, fSourceWidth, fSourceHeight, fWidthScale, fHeightScale, fVideoView->Bounds().Width() + 1, fVideoView->Bounds().Height() + 1);
sprintf(buf, "%s - %d x %d, %.3f:%.3f => %.0f x %.0f", NAME, fSourceWidth,
fSourceHeight, fWidthScale, fHeightScale,
fVideoView->Bounds().Width() + 1, fVideoView->Bounds().Height() + 1);
SetTitle(buf);
}
@@ -617,16 +724,18 @@ MainWin::AdjustFullscreenRenderer()
float max_height = fBackground->Bounds().Height() + 1.0f;
float scaled_width = fSourceWidth * fWidthScale;
float scaled_height = fSourceHeight * fHeightScale;
float factor = min_c(max_width / scaled_width, max_height / scaled_height);
float factor = min_c(max_width / scaled_width, max_height
/ scaled_height);
int render_width = int(scaled_width * factor);
int render_height = int(scaled_height * factor);
int x_ofs = (int(max_width) - render_width) / 2;
int y_ofs = (int(max_height) - render_height) / 2;
printf("AdjustFullscreenRenderer: background %.1f x %.1f, src video %d x %d, "
"scaled video %.3f x %.3f, factor %.3f, render %d x %d, x-ofs %d, y-ofs %d\n",
max_width, max_height, fSourceWidth, fSourceHeight, scaled_width, scaled_height,
factor, render_width, render_height, x_ofs, y_ofs);
printf("AdjustFullscreenRenderer: background %.1f x %.1f, src video "
"%d x %d, scaled video %.3f x %.3f, factor %.3f, render %d x %d, "
"x-ofs %d, y-ofs %d\n", max_width, max_height, fSourceWidth,
fSourceHeight, scaled_width, scaled_height, factor, render_width,
render_height, x_ofs, y_ofs);
fVideoView->MoveTo(x_ofs, y_ofs);
fVideoView->ResizeTo(render_width - 1, render_height - 1);
@@ -638,7 +747,8 @@ MainWin::AdjustFullscreenRenderer()
// no need to keep aspect ratio, make
// render cover the whole background
fVideoView->MoveTo(0, 0);
fVideoView->ResizeTo(fBackground->Bounds().Width(), fBackground->Bounds().Height());
fVideoView->ResizeTo(fBackground->Bounds().Width(),
fBackground->Bounds().Height());
}
}
@@ -652,24 +762,28 @@ MainWin::AdjustWindowedRenderer(bool user_resized)
// In windowed mode, the renderer always covers the
// whole background, accounting for the menu
fVideoView->MoveTo(0, fNoMenu ? 0 : fMenuBarHeight);
fVideoView->ResizeTo(fBackground->Bounds().Width(), fBackground->Bounds().Height() - (fNoMenu ? 0 : fMenuBarHeight));
fVideoView->ResizeTo(fBackground->Bounds().Width(),
fBackground->Bounds().Height() - (fNoMenu ? 0 : fMenuBarHeight));
if (fKeepAspectRatio) {
// To keep the aspect ratio correct, we
// do resize the window as required
float max_width = Bounds().Width() + 1.0f;
float max_height = Bounds().Height() + 1.0f - (fNoMenu ? 0 : fMenuBarHeight);
float max_height = Bounds().Height() + 1.0f - (fNoMenu ? 0
: fMenuBarHeight);
float scaled_width = fSourceWidth * fWidthScale;
float scaled_height = fSourceHeight * fHeightScale;
if (!user_resized && (scaled_width > max_width || scaled_height > max_height)) {
if (!user_resized && (scaled_width > max_width
|| scaled_height > max_height)) {
// A format switch occured, and the window was
// smaller then the video source. As it was not
// initiated by the user resizing the window, we
// enlarge the window to fit the video.
fIgnoreFrameResized = true;
ResizeTo(scaled_width - 1, scaled_height - 1 + (fNoMenu ? 0 : fMenuBarHeight));
ResizeTo(scaled_width - 1, scaled_height - 1
+ (fNoMenu ? 0 : fMenuBarHeight));
// Sync();
return;
}
@@ -678,13 +792,15 @@ MainWin::AdjustWindowedRenderer(bool user_resized)
int new_width = int(max_width);
int new_height = int(max_width / display_aspect_ratio + 0.5);
printf("AdjustWindowedRenderer: old display %d x %d, src video %d x %d, "
"scaled video %.3f x %.3f, aspect ratio %.3f, new display %d x %d\n",
int(max_width), int(max_height), fSourceWidth, fSourceHeight, scaled_width, scaled_height,
display_aspect_ratio, new_width, new_height);
printf("AdjustWindowedRenderer: old display %d x %d, src video "
"%d x %d, scaled video %.3f x %.3f, aspect ratio %.3f, new "
"display %d x %d\n", int(max_width), int(max_height),
fSourceWidth, fSourceHeight, scaled_width, scaled_height,
display_aspect_ratio, new_width, new_height);
fIgnoreFrameResized = true;
ResizeTo(new_width - 1, new_height - 1 + (fNoMenu ? 0 : fMenuBarHeight));
ResizeTo(new_width - 1, new_height - 1 + (fNoMenu ? 0
: fMenuBarHeight));
// Sync();
}
@@ -716,7 +832,8 @@ MainWin::ToggleFullscreen()
printf("ToggleFullscreen enter\n");
if (!fFrameResizedCalled) {
printf("ToggleFullscreen - ignoring, as FrameResized wasn't called since last switch\n");
printf("ToggleFullscreen - ignoring, as FrameResized wasn't called "
"since last switch\n");
return;
}
fFrameResizedCalled = false;
@@ -731,7 +848,9 @@ MainWin::ToggleFullscreen()
// Sync();
fSavedFrame = Frame();
printf("saving current frame: %d %d %d %d\n", int(fSavedFrame.left), int(fSavedFrame.top), int(fSavedFrame.right), int(fSavedFrame.bottom));
printf("saving current frame: %d %d %d %d\n", int(fSavedFrame.left),
int(fSavedFrame.top), int(fSavedFrame.right),
int(fSavedFrame.bottom));
BScreen screen(this);
BRect rect(screen.Frame());
@@ -860,7 +979,8 @@ MainWin::KeyDown(BMessage *msg)
uint32 raw_char = msg->FindInt32("raw_char");
uint32 modifiers = msg->FindInt32("modifiers");
printf("key 0x%lx, raw_char 0x%lx, modifiers 0x%lx\n", key, raw_char, modifiers);
printf("key 0x%lx, raw_char 0x%lx, modifiers 0x%lx\n", key, raw_char,
modifiers);
switch (raw_char) {
case B_SPACE:
@@ -882,7 +1002,8 @@ MainWin::KeyDown(BMessage *msg)
break;
case B_TAB:
if ((modifiers & (B_COMMAND_KEY | B_CONTROL_KEY | B_OPTION_KEY | B_MENU_KEY)) == 0) {
if ((modifiers & (B_COMMAND_KEY | B_CONTROL_KEY | B_OPTION_KEY
| B_MENU_KEY)) == 0) {
PostMessage(M_TOGGLE_FULLSCREEN);
return B_OK;
} else
@@ -974,14 +1095,18 @@ MainWin::KeyDown(BMessage *msg)
void
MainWin::DispatchMessage(BMessage *msg, BHandler *handler)
{
if ((msg->what == B_MOUSE_DOWN) && (handler == fBackground || handler == fVideoView))
if ((msg->what == B_MOUSE_DOWN) && (handler == fBackground
|| handler == fVideoView))
MouseDown(msg);
if ((msg->what == B_MOUSE_MOVED) && (handler == fBackground || handler == fVideoView))
if ((msg->what == B_MOUSE_MOVED) && (handler == fBackground
|| handler == fVideoView))
MouseMoved(msg);
if ((msg->what == B_MOUSE_UP) && (handler == fBackground || handler == fVideoView))
if ((msg->what == B_MOUSE_UP) && (handler == fBackground
|| handler == fVideoView))
MouseUp(msg);
if ((msg->what == B_KEY_DOWN) && (handler == fBackground || handler == fVideoView)) {
if ((msg->what == B_KEY_DOWN) && (handler == fBackground
|| handler == fVideoView)) {
// special case for PrintScreen key
if (msg->FindInt32("key") == B_PRINT_KEY) {
@@ -1103,19 +1228,34 @@ MainWin::MessageReceived(BMessage *msg)
break;
case M_FILE_ABOUT:
BAlert *alert;
alert = new BAlert("about", NAME"\n\n"
INFO1
#if TIME_BOMB_ACTIVE
"\n\n" INFO2
#endif
"\n\nCopyright "COPYRIGHT"\nVersion "VERSION"\nRevision "REVISION"\nBuild "BUILD, "OK");
if (fAlwaysOnTop) {
ToggleAlwaysOnTop();
alert->Go();
ToggleAlwaysOnTop();
} else {
alert->Go();
{
BString alertStr = fLocalizedName;
alertStr << "\n\n";
alertStr << fLocalizedInfo1;
#if TIME_BOMB_ACTIVE
alertStr << "\n\n";
alertStr << INFO2;
#endif
alertStr << "\n\nCopyright ";
alertStr << COPYRIGHT;
alertStr << B_TRANSLATE("\nVersion ");
alertStr << VERSION;
alertStr << B_TRANSLATE("\nRevision ");
if (strcmp(REVISION, "unknown") == 0)
alertStr << fLocalizedRevision;
else
alertStr << REVISION;
alertStr << B_TRANSLATE("\nBuild ");
alertStr << BUILD;
BAlert *alert;
alert = new BAlert("about", alertStr.String(), B_TRANSLATE("OK"));
if (fAlwaysOnTop) {
ToggleAlwaysOnTop();
alert->Go();
ToggleAlwaysOnTop();
} else
alert->Go();
}
break;
@@ -1130,7 +1270,8 @@ MainWin::MessageReceived(BMessage *msg)
ToggleFullscreen();
}
ResizeTo(int(fSourceWidth * fWidthScale),
int(fSourceHeight * fHeightScale) + (fNoMenu ? 0 : fMenuBarHeight));
int(fSourceHeight * fHeightScale) + (fNoMenu ? 0
: fMenuBarHeight));
// Sync();
break;
@@ -1167,11 +1308,13 @@ MainWin::MessageReceived(BMessage *msg)
break;
default:
if (msg->what >= M_SELECT_CHANNEL && msg->what <= M_SELECT_CHANNEL_END) {
if (msg->what >= M_SELECT_CHANNEL
&& msg->what <= M_SELECT_CHANNEL_END) {
SelectChannel(msg->what - M_SELECT_CHANNEL);
break;
}
if (msg->what >= M_SELECT_INTERFACE && msg->what <= M_SELECT_INTERFACE_END) {
if (msg->what >= M_SELECT_INTERFACE
&& msg->what <= M_SELECT_INTERFACE_END) {
SelectInterface(msg->what - M_SELECT_INTERFACE - 1);
break;
}
+5 -2
View File
@@ -25,10 +25,13 @@
#ifndef __MAIN_WIN_H
#define __MAIN_WIN_H
#include <Window.h>
#include <Menu.h>
#include <Button.h>
#include <Catalog.h>
#include <Locale.h>
#include <Menu.h>
#include <Slider.h>
#include <Window.h>
#include "Controller.h"
#include "VideoView.h"
+33 -15
View File
@@ -37,14 +37,16 @@
#include "VideoView.h"
void
overlay_copy(uint32 lines, void *dst, uint32 dst_bpr, const void *src, uint32 src_bpr)
overlay_copy(uint32 lines, void *dst, uint32 dst_bpr, const void *src,
uint32 src_bpr)
{
// bigtime_t start = system_time();
int len = min_c(dst_bpr, src_bpr);
// int len4 = len / 4;
while (lines--) {
/*
// this does not copy the last few bytes, if length is not aligned to 4 bytes
// this does not copy the last few bytes, if length is not aligned
// to 4 bytes
asm ("rep\n\t""movsl"
:
: "c" (len4), "S" (src), "D" (dst)
@@ -161,6 +163,10 @@ VideoNode:: HandleMessage(int32 message,
const void *data,
size_t size)
{
if (BBufferConsumer::HandleMessage(message, data, size) == B_OK
|| BMediaEventLooper::HandleMessage(message, data, size) == B_OK)
return B_OK;
return B_ERROR;
}
@@ -174,7 +180,9 @@ VideoNode::HandleEvent(const media_timed_event *event,
case BTimedEventQueue::B_START:
break;
case BTimedEventQueue::B_STOP:
EventQueue()->FlushEvents(event->event_time, BTimedEventQueue::B_ALWAYS, true, BTimedEventQueue::B_HANDLE_BUFFER);
EventQueue()->FlushEvents(event->event_time,
BTimedEventQueue::B_ALWAYS, true,
BTimedEventQueue::B_HANDLE_BUFFER);
break;
case BTimedEventQueue::B_HANDLE_BUFFER:
HandleBuffer((BBuffer *)event->pointer);
@@ -182,7 +190,7 @@ VideoNode::HandleEvent(const media_timed_event *event,
default:
printf("VideoNode::HandleEvent unknown event");
break;
}
}
}
@@ -258,13 +266,15 @@ VideoNode::Connected(const media_source &src,
fInput.format.u.raw_video.field_rate = 25.0;
color_space colorspace = format.u.raw_video.display.format;
BRect frame(0, 0, format.u.raw_video.display.line_width - 1, format.u.raw_video.display.line_count - 1);
BRect frame(0, 0, format.u.raw_video.display.line_width - 1,
format.u.raw_video.display.line_count - 1);
status_t err;
DeleteBuffers();
err = CreateBuffers(frame, colorspace, fOverlayEnabled);
if (err) {
printf("VideoNode::Connected failed, fOverlayEnabled = %d\n", fOverlayEnabled);
printf("VideoNode::Connected failed, fOverlayEnabled = %d\n",
fOverlayEnabled);
return err;
}
@@ -304,7 +314,8 @@ VideoNode::FormatChanged(const media_source &src,
return B_MEDIA_BAD_DESTINATION;
color_space colorspace = format.u.raw_video.display.format;
BRect frame(0, 0, format.u.raw_video.display.line_width - 1, format.u.raw_video.display.line_count - 1);
BRect frame(0, 0, format.u.raw_video.display.line_width - 1,
format.u.raw_video.display.line_count - 1);
status_t err;
DeleteBuffers();
@@ -312,7 +323,8 @@ VideoNode::FormatChanged(const media_source &src,
fVideoView->RemoveOverlay();
err = CreateBuffers(frame, colorspace, true); // try overlay
if (err) {
printf("VideoNode::FormatChanged creating overlay buffer failed\n");
printf("VideoNode::FormatChanged creating overlay buffer "
"failed\n");
err = CreateBuffers(frame, colorspace, false); // no overlay
}
} else {
@@ -343,11 +355,13 @@ VideoNode::HandleBuffer(BBuffer *buffer)
// memcpy(fBitmap->Bits(), buffer->Data(), fBitmap->BitsLength());
// fBitmap->SetBits(buffer->Data(), fBitmap->BitsLength(), 0, fInput.format.u.raw_video.display.format);
// fBitmap->SetBits(buffer->Data(), fBitmap->BitsLength(), 0,
// fInput.format.u.raw_video.display.format);
overlay_copy(fBitmap->Bounds().IntegerHeight() + 1,
fBitmap->Bits(), fBitmap->BytesPerRow(),
buffer->Data(), fInput.format.u.raw_video.display.bytes_per_row);
buffer->Data(),
fInput.format.u.raw_video.display.bytes_per_row);
fBitmap->UnlockBits();
@@ -357,7 +371,8 @@ VideoNode::HandleBuffer(BBuffer *buffer)
overlay_copy(fBitmap->Bounds().IntegerHeight() + 1,
fBitmap->Bits(), fBitmap->BytesPerRow(),
buffer->Data(), fInput.format.u.raw_video.display.bytes_per_row);
buffer->Data(),
fInput.format.u.raw_video.display.bytes_per_row);
}
// printf("overlay copy: %Ld usec\n", system_time() - start);
}
@@ -407,8 +422,9 @@ VideoNode::IsOverlayActive()
status_t
VideoNode::CreateBuffers(BRect frame, color_space cspace, bool overlay)
{
printf("VideoNode::CreateBuffers: frame %d,%d,%d,%d colorspace 0x%08x, overlay %d\n",
int(frame.left), int(frame.top), int(frame.right), int(frame.bottom), int(cspace), overlay);
printf("VideoNode::CreateBuffers: frame %d,%d,%d,%d colorspace 0x%08x, "
"overlay %d\n", int(frame.left), int(frame.top), int(frame.right),
int(frame.bottom), int(cspace), overlay);
// int32 bytesPerRow = B_ANY_BYTES_PER_ROW;
// if (cspace == B_YCbCr422)
@@ -418,7 +434,8 @@ VideoNode::CreateBuffers(BRect frame, color_space cspace, bool overlay)
LockBitmap();
ASSERT(fBitmap == 0);
uint32 flags = overlay ? (B_BITMAP_WILL_OVERLAY | B_BITMAP_RESERVE_OVERLAY_CHANNEL) : 0;
uint32 flags = overlay ? (B_BITMAP_WILL_OVERLAY
| B_BITMAP_RESERVE_OVERLAY_CHANNEL) : 0;
// fBitmap = new BBitmap(frame, flags, cspace, bytesPerRow);
fBitmap = new BBitmap(frame, flags, cspace);
if (!(fBitmap && fBitmap->InitCheck() == B_OK && fBitmap->IsValid())) {
@@ -429,7 +446,8 @@ VideoNode::CreateBuffers(BRect frame, color_space cspace, bool overlay)
printf("VideoNode::CreateBuffers failed\n");
return B_ERROR;
}
printf("overlay bitmap: got: bytes per row: %ld\n", fBitmap->BytesPerRow());
printf("overlay bitmap: got: bytes per row: %ld\n",
fBitmap->BytesPerRow());
fOverlayActive = overlay;
UnlockBitmap();
printf("VideoNode::CreateBuffers success\n");
+58 -28
View File
@@ -35,7 +35,8 @@
#define CHECK_ACTIVITY 'ChkA'
VideoView::VideoView(BRect frame, const char *name, uint32 resizeMask, uint32 flags)
VideoView::VideoView(BRect frame, const char *name, uint32 resizeMask,
uint32 flags)
: BView(frame, name, resizeMask, flags)
, fVideoNode(0)
, fVideoActive(false)
@@ -72,7 +73,8 @@ void
VideoView::AttachedToWindow()
{
BMessage msg(CHECK_ACTIVITY);
fActivityCheckMsgRunner = new BMessageRunner(BMessenger(this), &msg, 200000);
fActivityCheckMsgRunner = new BMessageRunner(BMessenger(this), &msg,
200000);
}
@@ -93,7 +95,8 @@ VideoView::OverlayLockAcquire()
void
VideoView::OverlayLockRelease()
{ /* [19:54] <Francois> Rudolf forwarded me a mail once about it
* [19:55] <Francois> when you get relmease msg you are supposed to UnlockBits() on the overlay bitmaps you use
* [19:55] <Francois> when you get relmease msg you are supposed to
UnlockBits() on the overlay bitmaps you use
* [19:55] <Francois> it's used when switching workspaces
* [19:55] <Francois> as the bits might get relocated
*/
@@ -139,7 +142,8 @@ VideoView::OverlayScreenshotCleanup()
if (bmp) {
DrawBitmap(bmp, Bounds());
SetViewOverlay(bmp, bmp->Bounds(), Bounds(), &fOverlayKeyColor,
B_FOLLOW_ALL, B_OVERLAY_FILTER_HORIZONTAL | B_OVERLAY_FILTER_VERTICAL);
B_FOLLOW_ALL, B_OVERLAY_FILTER_HORIZONTAL
| B_OVERLAY_FILTER_VERTICAL);
Invalidate();
}
}
@@ -231,7 +235,8 @@ VideoView::DrawFrame()
UnlockLooper();
fOverlayActive = false;
} else {
printf("can't ClearViewOverlay, as LockLooperWithTimeout failed\n");
printf("can't ClearViewOverlay, as LockLooperWithTimeout "
"failed\n");
}
}
if (want_overlay && !fOverlayActive) {
@@ -239,7 +244,8 @@ VideoView::DrawFrame()
BBitmap *bmp = fVideoNode->Bitmap();
if (bmp && LockLooperWithTimeout(50000) == B_OK) {
SetViewOverlay(bmp, bmp->Bounds(), Bounds(), &fOverlayKeyColor,
B_FOLLOW_ALL, B_OVERLAY_FILTER_HORIZONTAL | B_OVERLAY_FILTER_VERTICAL);
B_FOLLOW_ALL, B_OVERLAY_FILTER_HORIZONTAL
| B_OVERLAY_FILTER_VERTICAL);
fOverlayActive = true;
Invalidate();
@@ -363,31 +369,55 @@ VideoView::IsOverlaySupported()
bool supported = false;
for (int i = 0; colspace[i].name; i++) {
BBitmap *test = new BBitmap(BRect(0,0,320,240), B_BITMAP_WILL_OVERLAY | B_BITMAP_RESERVE_OVERLAY_CHANNEL, colspace[i].colspace);
BBitmap *test = new BBitmap(BRect(0,0,320,240), B_BITMAP_WILL_OVERLAY
| B_BITMAP_RESERVE_OVERLAY_CHANNEL, colspace[i].colspace);
if (test->InitCheck() == B_OK) {
printf("Display supports %s (0x%08x) overlay\n", colspace[i].name, colspace[i].colspace);
printf("Display supports %s (0x%08x) overlay\n", colspace[i].name,
colspace[i].colspace);
overlay_restrictions restrict;
if (B_OK == test->GetOverlayRestrictions(&restrict)) {
printf("Overlay restrictions: source horizontal_alignment %d\n", restrict.source.horizontal_alignment);
printf("Overlay restrictions: source vertical_alignment %d\n", restrict.source.vertical_alignment);
printf("Overlay restrictions: source width_alignment %d\n", restrict.source.width_alignment);
printf("Overlay restrictions: source height_alignment %d\n", restrict.source.height_alignment);
printf("Overlay restrictions: source min_width %d\n", restrict.source.min_width);
printf("Overlay restrictions: source max_width %d\n", restrict.source.max_width);
printf("Overlay restrictions: source min_height %d\n", restrict.source.min_height);
printf("Overlay restrictions: source max_height %d\n", restrict.source.max_height);
printf("Overlay restrictions: destination horizontal_alignment %d\n", restrict.destination.horizontal_alignment);
printf("Overlay restrictions: destination vertical_alignment %d\n", restrict.destination.vertical_alignment);
printf("Overlay restrictions: destination width_alignment %d\n", restrict.destination.width_alignment);
printf("Overlay restrictions: destination height_alignment %d\n", restrict.destination.height_alignment);
printf("Overlay restrictions: destination min_width %d\n", restrict.destination.min_width);
printf("Overlay restrictions: destination max_width %d\n", restrict.destination.max_width);
printf("Overlay restrictions: destination min_height %d\n", restrict.destination.min_height);
printf("Overlay restrictions: destination max_height %d\n", restrict.destination.max_height);
printf("Overlay restrictions: min_width_scale %.3f\n", restrict.min_width_scale);
printf("Overlay restrictions: max_width_scale %.3f\n", restrict.max_width_scale);
printf("Overlay restrictions: min_height_scale %.3f\n", restrict.min_height_scale);
printf("Overlay restrictions: max_height_scale %.3f\n", restrict.max_height_scale);
printf(
"Overlay restrictions: source horizontal_alignment %d\n",
restrict.source.horizontal_alignment);
printf("Overlay restrictions: source vertical_alignment %d\n",
restrict.source.vertical_alignment);
printf("Overlay restrictions: source width_alignment %d\n",
restrict.source.width_alignment);
printf("Overlay restrictions: source height_alignment %d\n",
restrict.source.height_alignment);
printf("Overlay restrictions: source min_width %d\n",
restrict.source.min_width);
printf("Overlay restrictions: source max_width %d\n",
restrict.source.max_width);
printf("Overlay restrictions: source min_height %d\n",
restrict.source.min_height);
printf("Overlay restrictions: source max_height %d\n",
restrict.source.max_height);
printf(
"Overlay restrictions: destination horizontal_alignment "
"%d\n", restrict.destination.horizontal_alignment);
printf("Overlay restrictions: destination vertical_alignment "
"%d\n", restrict.destination.vertical_alignment);
printf("Overlay restrictions: destination width_alignment "
"%d\n", restrict.destination.width_alignment);
printf("Overlay restrictions: destination height_alignment "
"%d\n", restrict.destination.height_alignment);
printf("Overlay restrictions: destination min_width %d\n",
restrict.destination.min_width);
printf("Overlay restrictions: destination max_width %d\n",
restrict.destination.max_width);
printf("Overlay restrictions: destination min_height %d\n",
restrict.destination.min_height);
printf("Overlay restrictions: destination max_height %d\n",
restrict.destination.max_height);
printf("Overlay restrictions: min_width_scale %.3f\n",
restrict.min_width_scale);
printf("Overlay restrictions: max_width_scale %.3f\n",
restrict.max_width_scale);
printf("Overlay restrictions: min_height_scale %.3f\n",
restrict.min_height_scale);
printf("Overlay restrictions: max_height_scale %.3f\n",
restrict.max_height_scale);
}
supported = true;
}