* Coding style cleanups, no functional change.

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@33811 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Axel Dörfler
2009-10-28 14:35:33 +00:00
parent ae3eeac13b
commit 2caab6e574
17 changed files with 264 additions and 247 deletions
+2
View File
@@ -19,6 +19,8 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
*/
#include "Controller.h"
#include <new>
+4 -3
View File
@@ -21,6 +21,7 @@
#ifndef __CONTROLLER_H
#define __CONTROLLER_H
#include <Entry.h>
#include <MediaDefs.h>
#include <MediaFormats.h>
@@ -33,6 +34,7 @@
#include "NodeManager.h"
#include "PlaylistItem.h"
class AudioTrackSupplier;
class BBitmap;
class BMediaFile;
@@ -44,9 +46,9 @@ class SoundOutput;
class VideoTrackSupplier;
class VideoView;
class Controller : public NodeManager {
public:
class Listener {
public:
Listener();
@@ -203,5 +205,4 @@ private:
};
#endif
#endif // __CONTROLLER_H
+5 -6
View File
@@ -1,20 +1,21 @@
/*
* Copyright 2007, Haiku. All rights reserved.
* Copyright 2007-2009, Haiku. All rights reserved.
* Distributed under the terms of the MIT License.
*
* Authors:
* Stephan Aßmus <[email protected]>
*/
#include "ControllerObserver.h"
#include <Message.h>
ControllerObserver::ControllerObserver(BHandler* target, uint32 observeFlags)
: Controller::Listener()
, AbstractLOAdapter(target)
, fObserveFlags(observeFlags)
:
AbstractLOAdapter(target),
fObserveFlags(observeFlags)
{
}
@@ -148,5 +149,3 @@ ControllerObserver::MutedChanged(bool muted)
DeliverMessage(message);
}
+8 -5
View File
@@ -1,5 +1,5 @@
/*
* Copyright 2007, Haiku. All rights reserved.
* Copyright 2007-2009, Haiku. All rights reserved.
* Distributed under the terms of the MIT License.
*
* Authors:
@@ -8,9 +8,11 @@
#ifndef CONTROLLER_OBSERVER_H
#define CONTROLLER_OBSERVER_H
#include "AbstractLOAdapter.h"
#include "Controller.h"
enum {
MSG_CONTROLLER_FILE_FINISHED = 'cnff',
MSG_CONTROLLER_FILE_CHANGED = 'cnfc',
@@ -38,9 +40,10 @@ enum {
OBSERVE_ALL_CHANGES = 0xffff
};
class ControllerObserver : public Controller::Listener,
public AbstractLOAdapter {
public:
class ControllerObserver
: public Controller::Listener, public AbstractLOAdapter {
public:
ControllerObserver(BHandler* target,
uint32 observeFlags = OBSERVE_ALL_CHANGES);
virtual ~ControllerObserver();
@@ -60,7 +63,7 @@ class ControllerObserver : public Controller::Listener,
virtual void VolumeChanged(float volume);
virtual void MutedChanged(bool muted);
private:
private:
uint32 fObserveFlags;
};
+9 -4
View File
@@ -19,6 +19,8 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
*/
#include "ControllerView.h"
#include <Autolock.h>
@@ -30,12 +32,14 @@
#include "Playlist.h"
#include "PlaylistObserver.h"
ControllerView::ControllerView(BRect frame, Controller* controller,
Playlist* playlist)
: TransportControlGroup(frame, true, true, false)
, fController(controller)
, fPlaylist(playlist)
, fPlaylistObserver(new PlaylistObserver(this))
:
TransportControlGroup(frame, true, true, false),
fController(controller),
fPlaylist(playlist),
fPlaylistObserver(new PlaylistObserver(this))
{
fPlaylist->AddListener(fPlaylistObserver);
}
@@ -78,6 +82,7 @@ ControllerView::MessageReceived(BMessage* message)
}
}
// #pragma mark -
+4 -4
View File
@@ -19,10 +19,10 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
*/
#ifndef __CONTROLLER_VIEW_H
#define __CONTROLLER_VIEW_H
#include "TransportControlGroup.h"
@@ -30,8 +30,8 @@ class Controller;
class Playlist;
class PlaylistObserver;
class ControllerView : public TransportControlGroup
{
class ControllerView : public TransportControlGroup {
public:
ControllerView(BRect frame, Controller* controller,
Playlist* playlist);
@@ -63,4 +63,4 @@ private:
PlaylistObserver* fPlaylistObserver;
};
#endif
#endif // __CONTROLLER_VIEW_H
+12 -21
View File
@@ -17,6 +17,8 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
*/
#include "InfoWin.h"
#include <math.h>
@@ -155,11 +157,12 @@ InfoView::SetGenericIcon()
InfoWin::InfoWin(BPoint leftTop, Controller* controller)
: BWindow(BRect(leftTop.x, leftTop.y, leftTop.x + MIN_WIDTH - 1,
:
BWindow(BRect(leftTop.x, leftTop.y, leftTop.x + MIN_WIDTH - 1,
leftTop.y + 300), NAME, B_TITLED_WINDOW,
B_ASYNCHRONOUS_CONTROLS | B_NOT_RESIZABLE | B_NOT_ZOOMABLE)
, fController(controller)
, fControllerObserver(new ControllerObserver(this,
B_ASYNCHRONOUS_CONTROLS | B_NOT_RESIZABLE | B_NOT_ZOOMABLE),
fController(controller),
fControllerObserver(new ControllerObserver(this,
OBSERVE_FILE_CHANGES | OBSERVE_TRACK_CHANGES | OBSERVE_STAT_CHANGES))
{
BRect rect = Bounds();
@@ -175,10 +178,9 @@ InfoWin::InfoWin(BPoint leftTop, Controller* controller)
bigFont.SetSize(bigFont.Size() + 6);
font_height fh;
bigFont.GetHeight(&fh);
fFilenameView = new BStringView(BRect(div + 10, 20,
rect.right - 10,
20 + fh.ascent + 5),
"filename", "");
fFilenameView = new BStringView(
BRect(div + 10, 20, rect.right - 10, 20 + fh.ascent + 5),
"filename", "");
AddChild(fFilenameView);
fFilenameView->SetFont(&bigFont);
fFilenameView->SetViewColor(fInfoView->ViewColor());
@@ -219,9 +221,6 @@ InfoWin::~InfoWin()
{
fController->RemoveListener(fControllerObserver);
delete fControllerObserver;
//fInfoListView->MakeEmpty();
//delete [] fInfoItems;
}
@@ -229,13 +228,13 @@ InfoWin::~InfoWin()
void
InfoWin::FrameResized(float new_width, float new_height)
InfoWin::FrameResized(float newWidth, float newHeight)
{
}
void
InfoWin::MessageReceived(BMessage *msg)
InfoWin::MessageReceived(BMessage* msg)
{
switch (msg->what) {
case MSG_CONTROLLER_FILE_FINISHED:
@@ -283,13 +282,6 @@ InfoWin::Pulse()
void
InfoWin::ResizeToPreferred()
{
#if 0
float height = BASE_HEIGHT;
for (int i = 0; BListItem *li = fInfoListView->ItemAt(i); i++) {
height += li->Height();
}
ResizeTo(Bounds().Width(), height);
#endif
}
@@ -469,7 +461,6 @@ printf("InfoWin::Update(0x%08lx)\n", which);
}
if ((which & INFO_COPYRIGHT) && fController->HasFile()) {
BString s;
if (fController->GetCopyright(&s) == B_OK && s.Length() > 0) {
fLabelsView->Insert("Copyright\n\n");
+5 -4
View File
@@ -20,6 +20,7 @@
#ifndef __FILE_INFO_WIN_H
#define __FILE_INFO_WIN_H
#include <Window.h>
@@ -28,7 +29,7 @@ class BTextView;
class Controller;
class ControllerObserver;
class InfoView;
#define INFO_STATS 0x00000001
#define INFO_TRANSPORT 0x00000002
@@ -45,7 +46,7 @@ public:
InfoWin(BPoint leftTop,
Controller* controller);
virtual ~InfoWin();
virtual void FrameResized(float newWidth, float newHeight);
virtual void MessageReceived(BMessage* message);
virtual bool QuitRequested();
@@ -54,10 +55,10 @@ public:
void ResizeToPreferred();
void Update(uint32 which = INFO_ALL);
private:
private:
Controller* fController;
ControllerObserver* fControllerObserver;
InfoView* fInfoView;
BStringView* fFilenameView;
BTextView* fLabelsView;
+20 -17
View File
@@ -18,6 +18,8 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
*/
#include "MainApp.h"
#include <Alert.h>
@@ -46,17 +48,18 @@ static const char* kMediaServerAddOnSig = "application/x-vnd.Be.addon-host";
MainApp::MainApp()
: BApplication(kAppSig),
fPlayerCount(0),
fFirstWindow(NULL),
fSettingsWindow(NULL),
:
BApplication(kAppSig),
fPlayerCount(0),
fFirstWindow(NULL),
fSettingsWindow(NULL),
fOpenFilePanel(NULL),
fSaveFilePanel(NULL),
fLastFilePanelFolder(),
fOpenFilePanel(NULL),
fSaveFilePanel(NULL),
fLastFilePanelFolder(),
fMediaServerRunning(false),
fMediaAddOnServerRunning(false)
fMediaServerRunning(false),
fMediaAddOnServerRunning(false)
{
mpSettings settings = Settings::CurrentSettings();
fLastFilePanelFolder = settings.filePanelFolder;
@@ -136,7 +139,7 @@ MainApp::ReadyToRun()
fMediaAddOnServerRunning = be_roster->IsRunning(kMediaServerAddOnSig);
if (!fMediaServerRunning || !fMediaAddOnServerRunning) {
BAlert* alert = new BAlert("start_media_server",
BAlert* alert = new BAlert("start_media_server",
"It appears the Media Server is not running.\n"
"Would you like to start it ?", "Quit", "Start Media Server", NULL,
B_WIDTH_AS_USUAL, B_WARNING_ALERT);
@@ -181,12 +184,12 @@ MainApp::RefsReceived(BMessage* message)
void
MainApp::ArgvReceived(int32 argc, char **argv)
MainApp::ArgvReceived(int32 argc, char** argv)
{
char cwd[B_PATH_NAME_LENGTH];
getcwd(cwd, sizeof(cwd));
BMessage m(B_REFS_RECEIVED);
BMessage message(B_REFS_RECEIVED);
for (int i = 1; i < argc; i++) {
printf("MainApp::ArgvReceived %s\n", argv[i]);
@@ -200,13 +203,13 @@ MainApp::ArgvReceived(int32 argc, char **argv)
continue;
entry_ref ref;
if (B_OK == entry.GetRef(&ref))
m.AddRef("refs", &ref);
if (entry.GetRef(&ref) == B_OK)
message.AddRef("refs", &ref);
}
if (m.HasRef("refs")) {
if (message.HasRef("refs")) {
printf("MainApp::ArgvReceived calling RefsReceived\n");
RefsReceived(&m);
RefsReceived(&message);
}
}
@@ -391,7 +394,7 @@ MainApp::_ShowFilePanel(BFilePanel* panel, uint32 command,
BMessage targetMessage;
if (message->FindMessage("message", &targetMessage) == B_OK)
panelMessage.AddMessage("message", &targetMessage);
BMessenger target;
if (message->FindMessenger("target", &target) == B_OK)
panelMessage.AddMessenger("target", target);
+2 -1
View File
@@ -21,6 +21,7 @@
#ifndef __MAIN_APP_H
#define __MAIN_APP_H
#include <Application.h>
#include <Entry.h>
@@ -100,4 +101,4 @@ private:
extern MainApp* gMainApp;
extern const char* kAppSig;
#endif
#endif // __MAIN_APP_H
+3 -1
View File
@@ -1,5 +1,5 @@
/*
* Copyright 2007, Haiku. All rights reserved.
* Copyright 2007-2009, Haiku. All rights reserved.
* Distributed under the terms of the MIT License.
*
* Authors:
@@ -8,10 +8,12 @@
#ifndef PLAYBACK_STATE_H
#define PLAYBACK_STATE_H
enum {
PLAYBACK_STATE_STOPPED = 0,
PLAYBACK_STATE_PLAYING = 1,
PLAYBACK_STATE_PAUSED = 2,
};
#endif // PLAYBACK_STATE_H
+65 -52
View File
@@ -49,14 +49,14 @@ enum {
#define kVolumeFactor 1000
#define kPositionFactor 3000
// constructor
TransportControlGroup::TransportControlGroup(BRect frame, bool useSkipButtons,
bool usePeakView, bool useWindButtons)
: BView(frame, "transport control group",
B_FOLLOW_LEFT_RIGHT | B_FOLLOW_TOP,
B_WILL_DRAW | B_FRAME_EVENTS)
, fBottomControlHeight(0.0)
, fPeakViewMinWidth(0.0)
:
BView(frame, "transport control group", B_FOLLOW_LEFT_RIGHT | B_FOLLOW_TOP,
B_WILL_DRAW | B_FRAME_EVENTS),
fBottomControlHeight(0.0),
fPeakViewMinWidth(0.0)
{
SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
@@ -141,7 +141,7 @@ TransportControlGroup::TransportControlGroup(BRect frame, bool useSkipButtons,
// Volume Slider
fVolumeSlider = new VolumeSlider(BRect(0.0, 0.0, VOLUME_MIN_WIDTH,
kVolumeSliderBitmapHeight - 1.0), "volume slider",
kVolumeSliderBitmapHeight - 1.0), "volume slider",
_DbToGain(_ExponentialToLinear(kVolumeDbMin)) * kVolumeFactor,
_DbToGain(_ExponentialToLinear(kVolumeDbMax)) * kVolumeFactor,
new BMessage(MSG_SET_VOLUME));
@@ -159,12 +159,12 @@ TransportControlGroup::TransportControlGroup(BRect frame, bool useSkipButtons,
}
}
// destructor
TransportControlGroup::~TransportControlGroup()
{
}
// AttachedToWindow
void
TransportControlGroup::AttachedToWindow()
{
@@ -188,7 +188,7 @@ TransportControlGroup::AttachedToWindow()
FrameResized(Bounds().Width(), Bounds().Height());
}
// FrameResized
void
TransportControlGroup::FrameResized(float width, float height)
{
@@ -198,7 +198,7 @@ TransportControlGroup::FrameResized(float width, float height)
_LayoutControls(r);
}
// GetPreferredSize
void
TransportControlGroup::GetPreferredSize(float* width, float* height)
{
@@ -210,7 +210,7 @@ TransportControlGroup::GetPreferredSize(float* width, float* height)
*height = r.Height();
}
// MessageReceived
void
TransportControlGroup::MessageReceived(BMessage* message)
{
@@ -253,55 +253,67 @@ TransportControlGroup::MessageReceived(BMessage* message)
}
}
// #pragma mark -
// default implementation for the virtuals
uint32 TransportControlGroup::EnabledButtons() { return 0; }
void TransportControlGroup::TogglePlaying() {}
void TransportControlGroup::Stop() {}
void TransportControlGroup::Rewind() {}
void TransportControlGroup::Forward() {}
void TransportControlGroup::SkipBackward() {}
void TransportControlGroup::SkipForward() {}
void TransportControlGroup::VolumeChanged(float value) {}
void TransportControlGroup::ToggleMute() {}
void TransportControlGroup::PositionChanged(float value){}
// #pragma mark - default implementation for the virtuals
uint32
TransportControlGroup::EnabledButtons()
{
return 0;
}
void TransportControlGroup::TogglePlaying() {}
void TransportControlGroup::Stop() {}
void TransportControlGroup::Rewind() {}
void TransportControlGroup::Forward() {}
void TransportControlGroup::SkipBackward() {}
void TransportControlGroup::SkipForward() {}
void TransportControlGroup::VolumeChanged(float value) {}
void TransportControlGroup::ToggleMute() {}
void TransportControlGroup::PositionChanged(float value) {}
// #pragma mark -
float
TransportControlGroup::_LinearToExponential(float db_in)
TransportControlGroup::_LinearToExponential(float dbIn)
{
float db = db_in;
float db = dbIn;
if (db >= 0) {
db = db * (pow(fabs(kVolumeDbMax), (1.0 / kVolumeDbExpPositive)) / fabs(kVolumeDbMax));
db = db * (pow(fabs(kVolumeDbMax), (1.0 / kVolumeDbExpPositive))
/ fabs(kVolumeDbMax));
db = pow(db, kVolumeDbExpPositive);
} else {
db = -db;
db = db * (pow(fabs(kVolumeDbMin), (1.0 / kVolumeDbExpNegative)) / fabs(kVolumeDbMin));
db = db * (pow(fabs(kVolumeDbMin), (1.0 / kVolumeDbExpNegative))
/ fabs(kVolumeDbMin));
db = pow(db, kVolumeDbExpNegative);
db = -db;
}
printf("_LinearToExponential %.4f => %.4f\n", db_in, db);
printf("_LinearToExponential %.4f => %.4f\n", dbIn, db);
return db;
}
float
TransportControlGroup::_ExponentialToLinear(float db_in)
TransportControlGroup::_ExponentialToLinear(float dbIn)
{
float db = db_in;
float db = dbIn;
if (db >= 0) {
db = pow(db, (1.0 / kVolumeDbExpPositive));
db = db * (fabs(kVolumeDbMax) / pow(fabs(kVolumeDbMax), (1.0 / kVolumeDbExpPositive)));
db = db * (fabs(kVolumeDbMax) / pow(fabs(kVolumeDbMax),
(1.0 / kVolumeDbExpPositive)));
} else {
db = -db;
db = pow(db, (1.0 / kVolumeDbExpNegative));
db = db * (fabs(kVolumeDbMin) / pow(fabs(kVolumeDbMin), (1.0 / kVolumeDbExpNegative)));
db = db * (fabs(kVolumeDbMin) / pow(fabs(kVolumeDbMin),
(1.0 / kVolumeDbExpNegative)));
db = -db;
}
//printf("_ExponentialToLinear %.4f => %.4f\n", db_in, db);
//printf("_ExponentialToLinear %.4f => %.4f\n", dbIn, db);
return db;
}
@@ -322,7 +334,7 @@ TransportControlGroup::_GainToDb(float gain)
// #pragma mark -
// SetEnabled
void
TransportControlGroup::SetEnabled(uint32 buttons)
{
@@ -349,9 +361,10 @@ TransportControlGroup::SetEnabled(uint32 buttons)
UnlockLooper();
}
// #pragma mark -
// SetPlaybackState
void
TransportControlGroup::SetPlaybackState(uint32 state)
{
@@ -373,7 +386,7 @@ TransportControlGroup::SetPlaybackState(uint32 state)
UnlockLooper();
}
// SetSkippable
void
TransportControlGroup::SetSkippable(bool backward, bool forward)
{
@@ -388,9 +401,10 @@ TransportControlGroup::SetSkippable(bool backward, bool forward)
UnlockLooper();
}
// #pragma mark -
// SetAudioEnabled
void
TransportControlGroup::SetAudioEnabled(bool enabled)
{
@@ -403,7 +417,7 @@ TransportControlGroup::SetAudioEnabled(bool enabled)
UnlockLooper();
}
// SetMuted
void
TransportControlGroup::SetMuted(bool mute)
{
@@ -440,7 +454,7 @@ TransportControlGroup::SetPosition(float value)
// #pragma mark -
// _LayoutControls
void
TransportControlGroup::_LayoutControls(BRect frame) const
{
@@ -535,8 +549,8 @@ TransportControlGroup::_LayoutControls(BRect frame) const
}
}
// _MinFrame
BRect
BRect
TransportControlGroup::_MinFrame() const
{
// add up width of controls along bottom (seek slider will likely adopt)
@@ -563,7 +577,7 @@ TransportControlGroup::_MinFrame() const
return BRect(0.0, 0.0, minWidth - 1.0, minHeight - 1.0);
}
// _LayoutControl
void
TransportControlGroup::_LayoutControl(BView* view, BRect frame,
bool resizeWidth, bool resizeHeight) const
@@ -581,14 +595,14 @@ TransportControlGroup::_LayoutControl(BView* view, BRect frame,
view->ResizeTo(width, height);
}
// _TogglePlaying
void
TransportControlGroup::_TogglePlaying()
{
TogglePlaying();
}
// _Stop
void
TransportControlGroup::_Stop()
{
@@ -596,34 +610,35 @@ TransportControlGroup::_Stop()
Stop();
}
// _Rewind
void
TransportControlGroup::_Rewind()
{
Rewind();
}
// _Forward
void
TransportControlGroup::_Forward()
{
Forward();
}
// _SkipBackward
void
TransportControlGroup::_SkipBackward()
{
SkipBackward();
}
// _SkipForward
void
TransportControlGroup::_SkipForward()
{
SkipForward();
}
void
TransportControlGroup::_UpdateVolume()
{
@@ -634,7 +649,7 @@ TransportControlGroup::_UpdateVolume()
VolumeChanged(gain);
}
// _ToggleMute
void
TransportControlGroup::_ToggleMute()
{
@@ -648,5 +663,3 @@ TransportControlGroup::_UpdatePosition()
{
PositionChanged(fSeekSlider->Value() / (float)kPositionFactor);
}
+14 -14
View File
@@ -1,17 +1,19 @@
/*
* Copyright © 2006-2008 Stephan Aßmus <superstippi@gmx.de>
* Copyright 2006-2008 Stephan Aßmus <superstippi@gmx.de>
* All rights reserved. Distributed under the terms of the MIT License.
*/
#ifndef TRANSPORT_CONTROL_GROUP_H
#define TRANSPORT_CONTROL_GROUP_H
// NOTE: Based on my code in the BeOS interface for the VLC media player
// that I did during the VLC 0.4.3 - 0.4.6 times. Code not written by me
// removed. -Stephan Aßmus
#ifndef TRANSPORT_CONTROL_GROUP_H
#define TRANSPORT_CONTROL_GROUP_H
#include <View.h>
class PeakView;
class PlayPauseButton;
class TransportButton;
@@ -28,11 +30,11 @@ enum {
SEEK_ENABLED = 1 << 6,
};
class TransportControlGroup : public BView {
public:
public:
TransportControlGroup(BRect frame,
bool useSkipButtons,
bool usePeakView,
bool useSkipButtons, bool usePeakView,
bool useWindButtons);
virtual ~TransportControlGroup();
@@ -56,9 +58,8 @@ class TransportControlGroup : public BView {
void SetEnabled(uint32 whichButtons);
void SetPlaybackState(uint32 state);
void SetSkippable(bool backward,
bool forward);
void SetPlaybackState(uint32 state);
void SetSkippable(bool backward, bool forward);
void SetAudioEnabled(bool enable);
void SetMuted(bool mute);
@@ -69,13 +70,12 @@ class TransportControlGroup : public BView {
PeakView* GetPeakView() const
{ return fPeakView; }
private:
private:
void _LayoutControls(BRect frame) const;
BRect _MinFrame() const;
void _LayoutControl(BView* view,
BRect frame,
bool resizeWidth = false,
bool resizeHeight = false) const;
void _LayoutControl(BView* view, BRect frame,
bool resizeWidth = false,
bool resizeHeight = false) const;
void _TogglePlaying();
void _Stop();
+39 -35
View File
@@ -1,34 +1,38 @@
/*
* Copyright (C) 2006 Marcus Overhagen <marcus@overhagen.de>. All rights reserved.
*
* Copyright 2006 Marcus Overhagen <marcus@overhagen.de>. All rights reserved.
* Distributed under the terms of the MIT License.
*/
#include <stdio.h>
#include <string.h>
#include <Window.h>
#include <TimeSource.h>
#include <MediaRoster.h>
#include <BufferGroup.h>
#include <Buffer.h>
#include <Bitmap.h>
#include <Locker.h>
#include <Debug.h>
#include "VideoNode.h"
#include <stdio.h>
#include <string.h>
#include <Bitmap.h>
#include <Buffer.h>
#include <BufferGroup.h>
#include <Debug.h>
#include <Locker.h>
#include <MediaRoster.h>
#include <TimeSource.h>
#include <Window.h>
#include "VideoView.h"
VideoNode::VideoNode(const char *name, VideoView *view)
: BMediaNode(name)
, BMediaEventLooper()
, BBufferConsumer(B_MEDIA_RAW_VIDEO)
, fVideoView(view)
, fInput()
, fOverlayEnabled(true)
, fOverlayActive(false)
, fDirectOverlayBuffer(false)
, fBitmap(0)
, fBitmapLocker(new BLocker("Video Node Locker"))
:
BMediaNode(name),
BMediaEventLooper(),
BBufferConsumer(B_MEDIA_RAW_VIDEO),
fVideoView(view),
fInput(),
fOverlayEnabled(true),
fOverlayActive(false),
fDirectOverlayBuffer(false),
fBitmap(0),
fBitmapLocker(new BLocker("Video Node Locker"))
{
}
@@ -129,7 +133,7 @@ VideoNode::HandleEvent(const media_timed_event *event,
default:
printf("VideoNode::HandleEvent unknown event");
break;
}
}
}
@@ -149,7 +153,7 @@ VideoNode::GetLatencyFor(const media_destination &dst,
{
if (dst != fInput.destination)
return B_MEDIA_BAD_DESTINATION;
*out_latency = 10000;
*out_id = TimeSource()->ID();
return B_OK;
@@ -166,18 +170,18 @@ VideoNode::AcceptFormat(const media_destination &dst,
* BBufferConsumer::Connected
* BBufferProducer::Connect
*/
if (dst != fInput.destination)
return B_MEDIA_BAD_DESTINATION;
return B_MEDIA_BAD_DESTINATION;
if (format->type == B_MEDIA_NO_TYPE)
format->type = B_MEDIA_RAW_VIDEO;
if (format->type != B_MEDIA_RAW_VIDEO)
return B_MEDIA_BAD_FORMAT;
return B_OK;
return B_OK;
}
@@ -213,12 +217,12 @@ VideoNode::Connected(const media_source &src,
if (err) {
printf("VideoNode::Connected failed, fOverlayEnabled = %d\n", fOverlayEnabled);
return err;
}
}
*out_input = fInput;
return B_OK;
}
@@ -268,12 +272,12 @@ VideoNode::FormatChanged(const media_source &src,
if (err) {
printf("VideoNode::FormatChanged failed (lost buffer group!)\n");
return B_MEDIA_BAD_FORMAT;
}
}
fInput.format = format;
//printf("VideoNode::FormatChanged leave\n");
return B_OK;
return B_OK;
}
@@ -281,7 +285,7 @@ void
VideoNode::HandleBuffer(BBuffer *buffer)
{
// printf("VideoNode::HandleBuffer\n");
LockBitmap();
if (fBitmap) {
// bigtime_t start = system_time();
@@ -341,7 +345,7 @@ 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",
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);
LockBitmap();
+61 -72
View File
@@ -1,92 +1,81 @@
/*
* Copyright (C) 2006 Marcus Overhagen <marcus@overhagen.de>. All rights reserved.
*
* Copyright 2006 Marcus Overhagen <marcus@overhagen.de>. All rights reserved.
* Distributed under the terms of the MIT License.
*/
#ifndef __VIDEO_NODE_H_
#define __VIDEO_NODE_H_
#include <BufferConsumer.h>
#include <MediaEventLooper.h>
class VideoView;
class VideoNode : public BMediaEventLooper, public BBufferConsumer
{
class VideoNode : public BMediaEventLooper, public BBufferConsumer {
public:
VideoNode(const char *name, VideoView *view);
~VideoNode();
VideoNode(const char* name, VideoView* view);
virtual ~VideoNode();
void SetOverlayEnabled(bool yesno);
bool IsOverlayActive();
void LockBitmap();
BBitmap * Bitmap();
void UnlockBitmap();
void SetOverlayEnabled(bool yesno);
bool IsOverlayActive();
protected:
BMediaAddOn * AddOn(int32 *internal_id) const;
void NodeRegistered();
void BufferReceived(BBuffer * buffer);
status_t GetNextInput(int32 *cookie, media_input *out_input);
void DisposeInputCookie(int32 cookie);
status_t HandleMessage(
int32 message,
const void *data,
size_t size);
void HandleEvent(
const media_timed_event *event,
bigtime_t lateness,
bool realTimeEvent);
status_t AcceptFormat(
const media_destination &dst,
media_format *format);
void ProducerDataStatus(
const media_destination &dst,
int32 status,
bigtime_t at_media_time);
status_t GetLatencyFor(
const media_destination &dst,
bigtime_t *out_latency,
media_node_id *out_id);
status_t Connected(
const media_source &src,
const media_destination &dst,
const media_format &format,
media_input *out_input);
void Disconnected(
const media_source &src,
const media_destination &dst);
status_t FormatChanged(
const media_source &src,
const media_destination &dst,
int32 from_change_count,
const media_format &format);
void LockBitmap();
BBitmap* Bitmap();
void UnlockBitmap();
protected:
void HandleBuffer(BBuffer *buffer);
status_t CreateBuffers(BRect frame, color_space cspace, bool overlay);
void DeleteBuffers();
virtual BMediaAddOn* AddOn(int32* internalID) const;
// BMediaEventLooper implementation
virtual void NodeRegistered();
virtual void HandleEvent(const media_timed_event* event,
bigtime_t lateness, bool realTimeEvent);
// BBuffer implementation
virtual status_t HandleMessage(int32 message, const void* data,
size_t size);
virtual status_t AcceptFormat(const media_destination& dest,
media_format* format);
virtual status_t GetNextInput(int32* cookie,
media_input* _input);
virtual void DisposeInputCookie(int32 cookie);
virtual void BufferReceived(BBuffer* buffer);
virtual void ProducerDataStatus(
const media_destination& dest, int32 status,
bigtime_t atMediaTime);
virtual status_t GetLatencyFor(const media_destination& dest,
bigtime_t* _latency, media_node_id* _id);
virtual status_t Connected(const media_source& source,
const media_destination& dest,
const media_format& format,
media_input* _input);
virtual void Disconnected(const media_source& source,
const media_destination& dest);
virtual status_t FormatChanged(const media_source& source,
const media_destination& dest,
int32 fromChangeCount,
const media_format& format);
protected:
VideoView * fVideoView;
media_input fInput;
bool fOverlayEnabled;
bool fOverlayActive;
bool fDirectOverlayBuffer; // If the overlay memory is directly written by the producer node.
BBitmap * fBitmap;
BLocker * fBitmapLocker;
void HandleBuffer(BBuffer* buffer);
status_t CreateBuffers(BRect frame, color_space space,
bool overlay);
void DeleteBuffers();
protected:
VideoView* fVideoView;
media_input fInput;
bool fOverlayEnabled;
bool fOverlayActive;
bool fDirectOverlayBuffer;
// If the overlay memory is directly written by the
// producer node.
BBitmap* fBitmap;
BLocker* fBitmapLocker;
};
#endif
#endif // __VIDEO_NODE_H_
+10 -7
View File
@@ -1,7 +1,9 @@
/*
* Copyright © 2006-2009 Stephan Aßmus <superstippi@gmx.de>
* Copyright 2006-2009 Stephan Aßmus <superstippi@gmx.de>
* All rights reserved. Distributed under the terms of the MIT license.
*/
#include "VideoView.h"
#include <stdio.h>
@@ -25,13 +27,14 @@
VideoView::VideoView(BRect frame, const char* name, uint32 resizeMask)
: BView(frame, name, resizeMask, B_WILL_DRAW | B_FULL_UPDATE_ON_RESIZE
:
BView(frame, name, resizeMask, B_WILL_DRAW | B_FULL_UPDATE_ON_RESIZE
| B_PULSE_NEEDED),
fOverlayMode(false),
fIsPlaying(false),
fIsFullscreen(false),
fLastMouseMove(system_time()),
fGlobalSettingsListener(this)
fOverlayMode(false),
fIsPlaying(false),
fIsFullscreen(false),
fLastMouseMove(system_time()),
fGlobalSettingsListener(this)
{
SetViewColor(B_TRANSPARENT_COLOR);
// might be reset to overlay key color if overlays are used
+1 -1
View File
@@ -1,5 +1,5 @@
/*
* Copyright © 2006-2009 Stephan Aßmus <superstippi@gmx.de>
* Copyright 2006-2009 Stephan Aßmus <superstippi@gmx.de>
* All rights reserved. Distributed under the terms of the MIT license.
*/
#ifndef VIDEO_VIEW_H