* re-enabled the InfoWin
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@21335 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -29,6 +29,7 @@
|
|||||||
#include <Debug.h>
|
#include <Debug.h>
|
||||||
#include <MediaFile.h>
|
#include <MediaFile.h>
|
||||||
#include <MediaTrack.h>
|
#include <MediaTrack.h>
|
||||||
|
#include <Path.h>
|
||||||
|
|
||||||
#include "ControllerView.h"
|
#include "ControllerView.h"
|
||||||
#include "PlaybackState.h"
|
#include "PlaybackState.h"
|
||||||
@@ -81,17 +82,12 @@ void Controller::Listener::VolumeChanged(float) {}
|
|||||||
|
|
||||||
Controller::Controller()
|
Controller::Controller()
|
||||||
: fVideoView(NULL)
|
: fVideoView(NULL)
|
||||||
, fName()
|
|
||||||
, fPaused(false)
|
, fPaused(false)
|
||||||
, fStopped(true)
|
, fStopped(true)
|
||||||
, fVolume(1.0)
|
, fVolume(1.0)
|
||||||
|
|
||||||
, fRef()
|
, fRef()
|
||||||
, fMediaFile(0)
|
, fMediaFile(0)
|
||||||
// TODO: remove, InfoWin depends on it but should be fixed
|
|
||||||
,fAudioTrack(0)
|
|
||||||
,fVideoTrack(0)
|
|
||||||
//
|
|
||||||
, fDataLock("controller data lock")
|
, fDataLock("controller data lock")
|
||||||
|
|
||||||
, fVideoSupplier(NULL)
|
, fVideoSupplier(NULL)
|
||||||
@@ -225,7 +221,6 @@ Controller::SetTo(const entry_ref &ref)
|
|||||||
fPauseAtEndOfStream = false;
|
fPauseAtEndOfStream = false;
|
||||||
fSeekToStartAfterPause = false;
|
fSeekToStartAfterPause = false;
|
||||||
fDuration = 0;
|
fDuration = 0;
|
||||||
fName = ref.name;
|
|
||||||
|
|
||||||
_UpdatePosition(0);
|
_UpdatePosition(0);
|
||||||
|
|
||||||
@@ -292,19 +287,16 @@ Controller::SetTo(const entry_ref &ref)
|
|||||||
void
|
void
|
||||||
Controller::GetSize(int *width, int *height)
|
Controller::GetSize(int *width, int *height)
|
||||||
{
|
{
|
||||||
// you need to hole the data lock
|
BAutolock _(fVideoSupplierLock);
|
||||||
|
|
||||||
media_format format;
|
if (fVideoSupplier) {
|
||||||
format.type = B_MEDIA_RAW_VIDEO;
|
media_format format = fVideoSupplier->Format();
|
||||||
format.u.raw_video = media_raw_video_format::wildcard;
|
// TODO: take aspect ratio into account!
|
||||||
format.u.raw_video.display.format = IsOverlayActive() ? B_YCbCr422 : B_RGB32;
|
|
||||||
|
|
||||||
if (!fVideoTrack || B_OK != fVideoTrack->DecodedFormat(&format)) {
|
|
||||||
*height = 480;
|
|
||||||
*width = 640;
|
|
||||||
} else {
|
|
||||||
*height = format.u.raw_video.display.line_count;
|
*height = format.u.raw_video.display.line_count;
|
||||||
*width = format.u.raw_video.display.line_width;
|
*width = format.u.raw_video.display.line_width;
|
||||||
|
} else {
|
||||||
|
*height = 480;
|
||||||
|
*width = 640;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -312,7 +304,8 @@ Controller::GetSize(int *width, int *height)
|
|||||||
int
|
int
|
||||||
Controller::AudioTrackCount()
|
Controller::AudioTrackCount()
|
||||||
{
|
{
|
||||||
// you need to hole the data lock
|
BAutolock _(fDataLock);
|
||||||
|
|
||||||
return fAudioTrackList->CountItems();
|
return fAudioTrackList->CountItems();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -320,7 +313,8 @@ Controller::AudioTrackCount()
|
|||||||
int
|
int
|
||||||
Controller::VideoTrackCount()
|
Controller::VideoTrackCount()
|
||||||
{
|
{
|
||||||
// you need to hole the data lock
|
BAutolock _(fDataLock);
|
||||||
|
|
||||||
return fVideoTrackList->CountItems();
|
return fVideoTrackList->CountItems();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -334,7 +328,6 @@ Controller::SelectAudioTrack(int n)
|
|||||||
if (!track)
|
if (!track)
|
||||||
return B_ERROR;
|
return B_ERROR;
|
||||||
|
|
||||||
fAudioTrack = track;
|
|
||||||
delete fAudioSupplier;
|
delete fAudioSupplier;
|
||||||
fAudioSupplier = new MediaTrackAudioSupplier(track);
|
fAudioSupplier = new MediaTrackAudioSupplier(track);
|
||||||
|
|
||||||
@@ -356,7 +349,6 @@ Controller::SelectVideoTrack(int n)
|
|||||||
if (!track)
|
if (!track)
|
||||||
return B_ERROR;
|
return B_ERROR;
|
||||||
|
|
||||||
fVideoTrack = track;
|
|
||||||
delete fVideoSupplier;
|
delete fVideoSupplier;
|
||||||
fVideoSupplier = new MediaTrackVideoSupplier(track,
|
fVideoSupplier = new MediaTrackVideoSupplier(track,
|
||||||
IsOverlayActive() ? B_YCbCr422 : B_RGB32);
|
IsOverlayActive() ? B_YCbCr422 : B_RGB32);
|
||||||
@@ -373,43 +365,6 @@ fVideoTrack = track;
|
|||||||
// #pragma mark -
|
// #pragma mark -
|
||||||
|
|
||||||
|
|
||||||
void
|
|
||||||
Controller::SetVolume(float value)
|
|
||||||
{
|
|
||||||
printf("Controller::SetVolume %.4f\n", value);
|
|
||||||
if (Lock()) {
|
|
||||||
fVolume = value;
|
|
||||||
if (fSoundOutput)
|
|
||||||
fSoundOutput->SetVolume(fVolume);
|
|
||||||
Unlock();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
float
|
|
||||||
Controller::Volume() const
|
|
||||||
{
|
|
||||||
BAutolock _(fDataLock);
|
|
||||||
|
|
||||||
return fVolume;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void
|
|
||||||
Controller::SetPosition(float value)
|
|
||||||
{
|
|
||||||
printf("Controller::SetPosition %.4f\n", value);
|
|
||||||
|
|
||||||
BAutolock _(fDataLock);
|
|
||||||
|
|
||||||
fSeekPosition = bigtime_t(value * Duration());
|
|
||||||
fSeekAudio = true;
|
|
||||||
fSeekVideo = true;
|
|
||||||
|
|
||||||
fSeekToStartAfterPause = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
Controller::Stop()
|
Controller::Stop()
|
||||||
{
|
{
|
||||||
@@ -532,6 +487,142 @@ Controller::Position()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
Controller::SetVolume(float value)
|
||||||
|
{
|
||||||
|
printf("Controller::SetVolume %.4f\n", value);
|
||||||
|
if (Lock()) {
|
||||||
|
fVolume = value;
|
||||||
|
if (fSoundOutput)
|
||||||
|
fSoundOutput->SetVolume(fVolume);
|
||||||
|
Unlock();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
float
|
||||||
|
Controller::Volume() const
|
||||||
|
{
|
||||||
|
BAutolock _(fDataLock);
|
||||||
|
|
||||||
|
return fVolume;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
Controller::SetPosition(float value)
|
||||||
|
{
|
||||||
|
printf("Controller::SetPosition %.4f\n", value);
|
||||||
|
|
||||||
|
BAutolock _(fDataLock);
|
||||||
|
|
||||||
|
fSeekPosition = bigtime_t(value * Duration());
|
||||||
|
fSeekAudio = true;
|
||||||
|
fSeekVideo = true;
|
||||||
|
|
||||||
|
fSeekToStartAfterPause = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// #pragma mark -
|
||||||
|
|
||||||
|
|
||||||
|
bool
|
||||||
|
Controller::HasFile()
|
||||||
|
{
|
||||||
|
// you need to hold the data lock
|
||||||
|
return fMediaFile != NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
status_t
|
||||||
|
Controller::GetFileFormatInfo(media_file_format* fileFormat)
|
||||||
|
{
|
||||||
|
// you need to hold the data lock
|
||||||
|
if (!fMediaFile)
|
||||||
|
return B_NO_INIT;
|
||||||
|
return fMediaFile->GetFileFormatInfo(fileFormat);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
status_t
|
||||||
|
Controller::GetCopyright(BString* copyright)
|
||||||
|
{
|
||||||
|
// you need to hold the data lock
|
||||||
|
if (!fMediaFile)
|
||||||
|
return B_NO_INIT;
|
||||||
|
*copyright = fMediaFile->Copyright();
|
||||||
|
return B_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
status_t
|
||||||
|
Controller::GetLocation(BString* location)
|
||||||
|
{
|
||||||
|
// you need to hold the data lock
|
||||||
|
if (!fMediaFile)
|
||||||
|
return B_NO_INIT;
|
||||||
|
BPath path(&fRef);
|
||||||
|
status_t ret = path.InitCheck();
|
||||||
|
if (ret < B_OK)
|
||||||
|
return ret;
|
||||||
|
*location = "";
|
||||||
|
*location << "file://" << path.Path();
|
||||||
|
return B_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
status_t
|
||||||
|
Controller::GetName(BString* name)
|
||||||
|
{
|
||||||
|
// you need to hold the data lock
|
||||||
|
if (!fMediaFile)
|
||||||
|
return B_NO_INIT;
|
||||||
|
*name = fRef.name;
|
||||||
|
return B_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
status_t
|
||||||
|
Controller::GetEncodedVideoFormat(media_format* format)
|
||||||
|
{
|
||||||
|
// you need to hold the data lock
|
||||||
|
if (fVideoSupplier)
|
||||||
|
return fVideoSupplier->GetEncodedFormat(format);
|
||||||
|
return B_NO_INIT;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
status_t
|
||||||
|
Controller::GetVideoCodecInfo(media_codec_info* info)
|
||||||
|
{
|
||||||
|
// you need to hold the data lock
|
||||||
|
if (fVideoSupplier)
|
||||||
|
return fVideoSupplier->GetCodecInfo(info);
|
||||||
|
return B_NO_INIT;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
status_t
|
||||||
|
Controller::GetEncodedAudioFormat(media_format* format)
|
||||||
|
{
|
||||||
|
// you need to hold the data lock
|
||||||
|
if (fAudioSupplier)
|
||||||
|
return fAudioSupplier->GetEncodedFormat(format);
|
||||||
|
return B_NO_INIT;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
status_t
|
||||||
|
Controller::GetAudioCodecInfo(media_codec_info* info)
|
||||||
|
{
|
||||||
|
// you need to hold the data lock
|
||||||
|
if (fAudioSupplier)
|
||||||
|
return fAudioSupplier->GetCodecInfo(info);
|
||||||
|
return B_NO_INIT;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// #pragma mark -
|
// #pragma mark -
|
||||||
|
|
||||||
|
|
||||||
@@ -735,7 +826,7 @@ printf("audio play start\n");
|
|||||||
if (!fSoundOutput
|
if (!fSoundOutput
|
||||||
|| !(fSoundOutput->Format() == buffer->mediaFormat.u.raw_audio)) {
|
|| !(fSoundOutput->Format() == buffer->mediaFormat.u.raw_audio)) {
|
||||||
delete fSoundOutput;
|
delete fSoundOutput;
|
||||||
fSoundOutput = new (nothrow) SoundOutput(fName.String(),
|
fSoundOutput = new (nothrow) SoundOutput(fRef.name,
|
||||||
buffer->mediaFormat.u.raw_audio);
|
buffer->mediaFormat.u.raw_audio);
|
||||||
fSoundOutput->SetVolume(fVolume);
|
fSoundOutput->SetVolume(fVolume);
|
||||||
bufferDuration = bigtime_t(1000000.0
|
bufferDuration = bigtime_t(1000000.0
|
||||||
|
|||||||
@@ -23,6 +23,7 @@
|
|||||||
|
|
||||||
#include <Entry.h>
|
#include <Entry.h>
|
||||||
#include <MediaDefs.h>
|
#include <MediaDefs.h>
|
||||||
|
#include <MediaFormats.h>
|
||||||
#include <MediaNode.h>
|
#include <MediaNode.h>
|
||||||
#include <List.h>
|
#include <List.h>
|
||||||
#include <Locker.h>
|
#include <Locker.h>
|
||||||
@@ -90,6 +91,16 @@ public:
|
|||||||
float Volume() const;
|
float Volume() const;
|
||||||
void SetPosition(float value);
|
void SetPosition(float value);
|
||||||
|
|
||||||
|
bool HasFile();
|
||||||
|
status_t GetFileFormatInfo(media_file_format* fileFormat);
|
||||||
|
status_t GetCopyright(BString* copyright);
|
||||||
|
status_t GetLocation(BString* location);
|
||||||
|
status_t GetName(BString* name);
|
||||||
|
status_t GetEncodedVideoFormat(media_format* format);
|
||||||
|
status_t GetVideoCodecInfo(media_codec_info* info);
|
||||||
|
status_t GetEncodedAudioFormat(media_format* format);
|
||||||
|
status_t GetAudioCodecInfo(media_codec_info* info);
|
||||||
|
|
||||||
// video view
|
// video view
|
||||||
void SetVideoView(VideoView *view);
|
void SetVideoView(VideoView *view);
|
||||||
|
|
||||||
@@ -155,15 +166,12 @@ private:
|
|||||||
};
|
};
|
||||||
|
|
||||||
VideoView * fVideoView;
|
VideoView * fVideoView;
|
||||||
BString fName;
|
|
||||||
volatile bool fPaused;
|
volatile bool fPaused;
|
||||||
volatile bool fStopped;
|
volatile bool fStopped;
|
||||||
float fVolume;
|
float fVolume;
|
||||||
|
|
||||||
entry_ref fRef;
|
entry_ref fRef;
|
||||||
BMediaFile * fMediaFile;
|
BMediaFile * fMediaFile;
|
||||||
BMediaTrack * fAudioTrack;
|
|
||||||
BMediaTrack * fVideoTrack;
|
|
||||||
mutable BLocker fDataLock;
|
mutable BLocker fDataLock;
|
||||||
|
|
||||||
VideoSupplier* fVideoSupplier;
|
VideoSupplier* fVideoSupplier;
|
||||||
|
|||||||
+226
-248
@@ -19,22 +19,24 @@
|
|||||||
*/
|
*/
|
||||||
#include "InfoWin.h"
|
#include "InfoWin.h"
|
||||||
|
|
||||||
#include <View.h>
|
#include <math.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <String.h>
|
|
||||||
#include <Debug.h>
|
#include <Debug.h>
|
||||||
#include <MediaDefs.h>
|
#include <MediaDefs.h>
|
||||||
#include <MediaFile.h>
|
#include <String.h>
|
||||||
#include <MediaTrack.h>
|
#include <StringView.h>
|
||||||
#include <TextView.h>
|
#include <TextView.h>
|
||||||
#include <math.h>
|
|
||||||
#include "MainWin.h"
|
#include "Controller.h"
|
||||||
|
#include "ControllerObserver.h"
|
||||||
|
|
||||||
|
|
||||||
#define NAME "File Info"
|
#define NAME "File Info"
|
||||||
#define MIN_WIDTH 350
|
#define MIN_WIDTH 350
|
||||||
|
|
||||||
#define BASE_HEIGHT (32+32)
|
#define BASE_HEIGHT (32 + 32)
|
||||||
|
|
||||||
//const rgb_color kGreen = { 152, 203, 152, 255 };
|
//const rgb_color kGreen = { 152, 203, 152, 255 };
|
||||||
const rgb_color kRed = { 203, 152, 152, 255 };
|
const rgb_color kRed = { 203, 152, 152, 255 };
|
||||||
@@ -47,7 +49,8 @@ const rgb_color kBlack = { 0, 0, 0, 255 };
|
|||||||
class InfoView : public BView {
|
class InfoView : public BView {
|
||||||
public:
|
public:
|
||||||
InfoView(BRect frame, const char *name, float divider)
|
InfoView(BRect frame, const char *name, float divider)
|
||||||
: BView(frame, name, B_FOLLOW_ALL, B_WILL_DRAW | B_FULL_UPDATE_ON_RESIZE)
|
: BView(frame, name, B_FOLLOW_ALL,
|
||||||
|
B_WILL_DRAW | B_FULL_UPDATE_ON_RESIZE)
|
||||||
, fDivider(divider)
|
, fDivider(divider)
|
||||||
{ }
|
{ }
|
||||||
virtual ~InfoView()
|
virtual ~InfoView()
|
||||||
@@ -70,27 +73,31 @@ InfoView::Draw(BRect updateRect)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// #pragma mark -
|
||||||
|
|
||||||
|
|
||||||
InfoWin::InfoWin(BPoint leftTop, Controller* controller)
|
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 + 250), NAME, B_TITLED_WINDOW,
|
leftTop.y + 250), NAME, B_TITLED_WINDOW,
|
||||||
B_ASYNCHRONOUS_CONTROLS | B_NOT_RESIZABLE),
|
B_ASYNCHRONOUS_CONTROLS | B_NOT_RESIZABLE)
|
||||||
fController(controller)
|
, fController(controller)
|
||||||
|
, fControllerObserver(new ControllerObserver(this,
|
||||||
|
OBSERVE_FILE_CHANGES | OBSERVE_TRACK_CHANGES | OBSERVE_STAT_CHANGES))
|
||||||
{
|
{
|
||||||
BRect rect = Bounds();
|
BRect rect = Bounds();
|
||||||
|
|
||||||
// accomodate for big fonts
|
// accomodate for big fonts
|
||||||
float div;
|
float div = max_c(2 * 32, be_plain_font->StringWidth("Container") + 5);
|
||||||
div = MAX(2*32, be_plain_font->StringWidth("Container") + 5);
|
|
||||||
|
|
||||||
fInfoView = new InfoView(rect, "background", div);
|
fInfoView = new InfoView(rect, "background", div);
|
||||||
fInfoView->SetViewColor(ui_color(B_DOCUMENT_BACKGROUND_COLOR));
|
fInfoView->SetViewColor(ui_color(B_DOCUMENT_BACKGROUND_COLOR));
|
||||||
AddChild(fInfoView);
|
AddChild(fInfoView);
|
||||||
|
|
||||||
BFont bigFont(be_plain_font);
|
BFont bigFont(be_plain_font);
|
||||||
bigFont.SetSize(bigFont.Size()+6);
|
bigFont.SetSize(bigFont.Size() + 6);
|
||||||
font_height fh;
|
font_height fh;
|
||||||
bigFont.GetHeight(&fh);
|
bigFont.GetHeight(&fh);
|
||||||
fFilenameView = new BStringView(BRect(div+10, 20,
|
fFilenameView = new BStringView(BRect(div + 10, 20,
|
||||||
rect.right - 10,
|
rect.right - 10,
|
||||||
20 + fh.ascent + 5),
|
20 + fh.ascent + 5),
|
||||||
"filename", "");
|
"filename", "");
|
||||||
@@ -110,13 +117,13 @@ InfoWin::InfoWin(BPoint leftTop, Controller* controller)
|
|||||||
lr.right = div - 1;
|
lr.right = div - 1;
|
||||||
cr.left = div + 1;
|
cr.left = div + 1;
|
||||||
BRect tr;
|
BRect tr;
|
||||||
tr = lr.OffsetToCopy(0,0).InsetByCopy(1,1);
|
tr = lr.OffsetToCopy(0, 0).InsetByCopy(5, 1);
|
||||||
fLabelsView = new BTextView(lr, "labels", tr, B_FOLLOW_BOTTOM);
|
fLabelsView = new BTextView(lr, "labels", tr, B_FOLLOW_BOTTOM);
|
||||||
fLabelsView->SetViewColor(kGreen);
|
fLabelsView->SetViewColor(kGreen);
|
||||||
fLabelsView->SetAlignment(B_ALIGN_RIGHT);
|
fLabelsView->SetAlignment(B_ALIGN_RIGHT);
|
||||||
fLabelsView->SetWordWrap(false);
|
fLabelsView->SetWordWrap(false);
|
||||||
AddChild(fLabelsView);
|
AddChild(fLabelsView);
|
||||||
tr = cr.OffsetToCopy(0,0).InsetByCopy(1,1);
|
tr = cr.OffsetToCopy(0, 0).InsetByCopy(10, 1);
|
||||||
fContentsView = new BTextView(cr, "contents", tr, B_FOLLOW_BOTTOM);
|
fContentsView = new BTextView(cr, "contents", tr, B_FOLLOW_BOTTOM);
|
||||||
fContentsView->SetWordWrap(false);
|
fContentsView->SetWordWrap(false);
|
||||||
AddChild(fContentsView);
|
AddChild(fContentsView);
|
||||||
@@ -124,6 +131,8 @@ InfoWin::InfoWin(BPoint leftTop, Controller* controller)
|
|||||||
fLabelsView->MakeSelectable();
|
fLabelsView->MakeSelectable();
|
||||||
fContentsView->MakeSelectable();
|
fContentsView->MakeSelectable();
|
||||||
|
|
||||||
|
fController->AddListener(fControllerObserver);
|
||||||
|
Update();
|
||||||
|
|
||||||
Show();
|
Show();
|
||||||
}
|
}
|
||||||
@@ -131,188 +140,46 @@ InfoWin::InfoWin(BPoint leftTop, Controller* controller)
|
|||||||
|
|
||||||
InfoWin::~InfoWin()
|
InfoWin::~InfoWin()
|
||||||
{
|
{
|
||||||
printf("InfoWin::~InfoWin\n");
|
fController->RemoveListener(fControllerObserver);
|
||||||
|
delete fControllerObserver;
|
||||||
|
|
||||||
//fInfoListView->MakeEmpty();
|
//fInfoListView->MakeEmpty();
|
||||||
//delete [] fInfoItems;
|
//delete [] fInfoItems;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// #pragma mark -
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
InfoWin::ResizeToPreferred()
|
InfoWin::FrameResized(float new_width, float new_height)
|
||||||
{
|
{
|
||||||
#if 0
|
|
||||||
int i;
|
|
||||||
float height = BASE_HEIGHT;
|
|
||||||
BListItem *li;
|
|
||||||
for (i = 0; (li = fInfoListView->ItemAt(i)); i++) {
|
|
||||||
height += li->Height();
|
|
||||||
}
|
|
||||||
ResizeTo(Bounds().Width(), height);
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
InfoWin::Update(uint32 which)
|
InfoWin::MessageReceived(BMessage *msg)
|
||||||
{
|
{
|
||||||
// status_t err;
|
switch (msg->what) {
|
||||||
// //char buf[256];
|
case MSG_CONTROLLER_FILE_FINISHED:
|
||||||
// printf("InfoWin::Update(0x%08lx)\n", which);
|
break;
|
||||||
// rgb_color vFgCol = ui_color(B_DOCUMENT_TEXT_COLOR);
|
case MSG_CONTROLLER_FILE_CHANGED:
|
||||||
//
|
Update(INFO_ALL);
|
||||||
// fLabelsView->SelectAll();
|
break;
|
||||||
// fContentsView->SelectAll();
|
case MSG_CONTROLLER_VIDEO_TRACK_CHANGED:
|
||||||
// fLabelsView->Clear();
|
Update(/*INFO_VIDEO | INFO_STATS*/INFO_ALL);
|
||||||
// fContentsView->Clear();
|
break;
|
||||||
// fLabelsView->SetFontAndColor(be_plain_font, B_FONT_ALL, &kBlue);
|
case MSG_CONTROLLER_AUDIO_TRACK_CHANGED:
|
||||||
// fLabelsView->Insert("File Info\n");
|
Update(/*INFO_AUDIO | INFO_STATS*/INFO_ALL);
|
||||||
// fContentsView->SetFontAndColor(be_plain_font, B_FONT_ALL, &vFgCol);
|
break;
|
||||||
// fContentsView->Insert("\n");
|
case MSG_CONTROLLER_VIDEO_STATS_CHANGED:
|
||||||
//
|
case MSG_CONTROLLER_AUDIO_STATS_CHANGED:
|
||||||
// fLabelsView->SetFontAndColor(be_plain_font, B_FONT_ALL, &kRed);
|
Update(/*INFO_STATS*/INFO_ALL);
|
||||||
// //fContentsView->SetFontAndColor(be_plain_font, B_FONT_ALL, &vFgCol);
|
break;
|
||||||
//
|
default:
|
||||||
// // lock the Main Window as we must access some fields there...
|
BWindow::MessageReceived(msg);
|
||||||
// if (fMainWin->LockWithTimeout(500000) < B_OK)
|
break;
|
||||||
// return; // XXX: resend msg to ourselves ?
|
}
|
||||||
//
|
|
||||||
// Controller *c = fMainWin->fController;
|
|
||||||
// BMediaFile *mf = c->fMediaFile;
|
|
||||||
//
|
|
||||||
// if (which & INFO_VIDEO && c->VideoTrackCount() > 0) {
|
|
||||||
// fLabelsView->Insert("Video\n\n");
|
|
||||||
// BString s;
|
|
||||||
// media_format fmt;
|
|
||||||
// media_raw_video_format vfmt;
|
|
||||||
// float fps;
|
|
||||||
// err = c->fVideoTrack->EncodedFormat(&fmt);
|
|
||||||
// //string_for_format(fmt, buf, sizeof(buf));
|
|
||||||
// //printf("%s\n", buf);
|
|
||||||
// if (err < 0) {
|
|
||||||
// s << "(" << strerror(err) << ")";
|
|
||||||
// } else if (fmt.type == B_MEDIA_ENCODED_VIDEO) {
|
|
||||||
// vfmt = fmt.u.encoded_video.output;
|
|
||||||
// media_codec_info mci;
|
|
||||||
// err = c->fVideoTrack->GetCodecInfo(&mci);
|
|
||||||
// if (err < 0)
|
|
||||||
// s << "(" << strerror(err) << ")";
|
|
||||||
// else
|
|
||||||
// s << mci.pretty_name; //<< "(" << mci.short_name << ")";
|
|
||||||
// } else if (fmt.type == B_MEDIA_RAW_VIDEO) {
|
|
||||||
// vfmt = fmt.u.raw_video;
|
|
||||||
// s << "raw video";
|
|
||||||
// } else
|
|
||||||
// s << "unknown format";
|
|
||||||
// s << "\n";
|
|
||||||
// s << fmt.Width() << " x " << fmt.Height();
|
|
||||||
// // encoded has output as 1st field...
|
|
||||||
// fps = vfmt.field_rate;
|
|
||||||
// s << ", " << fps << " fps";
|
|
||||||
// s << "\n";
|
|
||||||
// fContentsView->Insert(s.String());
|
|
||||||
// }
|
|
||||||
// if (which & INFO_AUDIO && c->AudioTrackCount() > 0) {
|
|
||||||
// fLabelsView->Insert("Sound\n\n");
|
|
||||||
// BString s;
|
|
||||||
// media_format fmt;
|
|
||||||
// media_raw_audio_format afmt;
|
|
||||||
// err = c->fAudioTrack->EncodedFormat(&fmt);
|
|
||||||
// //string_for_format(fmt, buf, sizeof(buf));
|
|
||||||
// //printf("%s\n", buf);
|
|
||||||
// if (err < 0) {
|
|
||||||
// s << "(" << strerror(err) << ")";
|
|
||||||
// } else if (fmt.type == B_MEDIA_ENCODED_AUDIO) {
|
|
||||||
// afmt = fmt.u.encoded_audio.output;
|
|
||||||
// media_codec_info mci;
|
|
||||||
// err = c->fAudioTrack->GetCodecInfo(&mci);
|
|
||||||
// if (err < 0)
|
|
||||||
// s << "(" << strerror(err) << ")";
|
|
||||||
// else
|
|
||||||
// s << mci.pretty_name; //<< "(" << mci.short_name << ")";
|
|
||||||
// } else if (fmt.type == B_MEDIA_RAW_AUDIO) {
|
|
||||||
// afmt = fmt.u.raw_audio;
|
|
||||||
// s << "raw audio";
|
|
||||||
// } else
|
|
||||||
// s << "unknown format";
|
|
||||||
// s << "\n";
|
|
||||||
// uint32 bitps = 8 * (afmt.format & media_raw_audio_format::B_AUDIO_SIZE_MASK);
|
|
||||||
// uint32 chans = afmt.channel_count;
|
|
||||||
// float sr = afmt.frame_rate;
|
|
||||||
//
|
|
||||||
// if (bitps)
|
|
||||||
// s << bitps << " Bit ";
|
|
||||||
// if (chans == 1)
|
|
||||||
// s << "Mono";
|
|
||||||
// else if (chans == 2)
|
|
||||||
// s << "Stereo";
|
|
||||||
// else
|
|
||||||
// s << chans << "Channels";
|
|
||||||
// s << ", ";
|
|
||||||
// if (sr)
|
|
||||||
// s << sr/1000;
|
|
||||||
// else
|
|
||||||
// s << "?";
|
|
||||||
// s<< " kHz";
|
|
||||||
// s << "\n";
|
|
||||||
// fContentsView->Insert(s.String());
|
|
||||||
// }
|
|
||||||
// if (which & INFO_STATS && fMainWin->fHasFile) {
|
|
||||||
// // TODO: check for live streams (no duration)
|
|
||||||
// fLabelsView->Insert("Duration\n");
|
|
||||||
// BString s;
|
|
||||||
// bigtime_t d = c->Duration();
|
|
||||||
// bigtime_t v;
|
|
||||||
//
|
|
||||||
// //s << d << "µs; ";
|
|
||||||
//
|
|
||||||
// d /= 1000;
|
|
||||||
//
|
|
||||||
// v = d / (3600 * 1000);
|
|
||||||
// d = d % (3600 * 1000);
|
|
||||||
// if (v)
|
|
||||||
// s << v << ":";
|
|
||||||
// v = d / (60 * 1000);
|
|
||||||
// d = d % (60 * 1000);
|
|
||||||
// s << v << ":";
|
|
||||||
// v = d / 1000;
|
|
||||||
// d = d % 1000;
|
|
||||||
// s << v;
|
|
||||||
// if (d)
|
|
||||||
// s << "." << d / 10;
|
|
||||||
// s << "\n";
|
|
||||||
// fContentsView->Insert(s.String());
|
|
||||||
// // TODO: demux/video/audio/... perfs (Kb/s)
|
|
||||||
// }
|
|
||||||
// if (which & INFO_TRANSPORT) {
|
|
||||||
// }
|
|
||||||
// if ((which & INFO_FILE) && fMainWin->fHasFile) {
|
|
||||||
// media_file_format ff;
|
|
||||||
// if (mf && (mf->GetFileFormatInfo(&ff) == B_OK)) {
|
|
||||||
// fLabelsView->Insert("Container\n");
|
|
||||||
// BString s;
|
|
||||||
// s << ff.pretty_name;
|
|
||||||
// s << "\n";
|
|
||||||
// fContentsView->Insert(s.String());
|
|
||||||
// }
|
|
||||||
// fLabelsView->Insert("Location\n");
|
|
||||||
// // TODO: make Controller save the entry_ref (url actually).
|
|
||||||
// fContentsView->Insert("file://\n");
|
|
||||||
// fFilenameView->SetText(c->fName.String());
|
|
||||||
// }
|
|
||||||
// if (which & INFO_COPYRIGHT && mf && mf->Copyright()) {
|
|
||||||
//
|
|
||||||
// fLabelsView->Insert("Copyright\n\n");
|
|
||||||
// BString s;
|
|
||||||
// s << mf->Copyright();
|
|
||||||
// s << "\n\n";
|
|
||||||
// fContentsView->Insert(s.String());
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// // we can unlock the main window now and let it work
|
|
||||||
// fMainWin->Unlock();
|
|
||||||
//
|
|
||||||
// // now resize the window to the list view size...
|
|
||||||
// ResizeToPreferred();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -332,77 +199,188 @@ InfoWin::Pulse()
|
|||||||
Update(INFO_STATS);
|
Update(INFO_STATS);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// #pragma mark -
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
InfoWin::FrameResized(float new_width, float new_height)
|
InfoWin::ResizeToPreferred()
|
||||||
{
|
{
|
||||||
#if 0
|
#if 0
|
||||||
if (new_width != Bounds().Width() || new_height != Bounds().Height()) {
|
float height = BASE_HEIGHT;
|
||||||
debugger("size wrong\n");
|
for (int i = 0; BListItem *li = fInfoListView->ItemAt(i); i++) {
|
||||||
}
|
height += li->Height();
|
||||||
|
|
||||||
bool no_menu = fNoMenu || fIsFullscreen;
|
|
||||||
bool no_controls = fNoControls || fIsFullscreen;
|
|
||||||
|
|
||||||
printf("FrameResized enter: new_width %.0f, new_height %.0f\n", new_width, new_height);
|
|
||||||
|
|
||||||
int max_video_width = int(new_width) + 1;
|
|
||||||
int max_video_height = int(new_height) + 1 - (no_menu ? 0 : fMenuBarHeight) - (no_controls ? 0 : fControlsHeight);
|
|
||||||
|
|
||||||
ASSERT(max_video_height >= 0);
|
|
||||||
|
|
||||||
int y = 0;
|
|
||||||
|
|
||||||
if (no_menu) {
|
|
||||||
if (!fMenuBar->IsHidden())
|
|
||||||
fMenuBar->Hide();
|
|
||||||
} else {
|
|
||||||
// fMenuBar->MoveTo(0, y);
|
|
||||||
fMenuBar->ResizeTo(new_width, fMenuBarHeight - 1);
|
|
||||||
if (fMenuBar->IsHidden())
|
|
||||||
fMenuBar->Show();
|
|
||||||
y += fMenuBarHeight;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (max_video_height == 0) {
|
|
||||||
if (!fVideoView->IsHidden())
|
|
||||||
fVideoView->Hide();
|
|
||||||
} else {
|
|
||||||
// fVideoView->MoveTo(0, y);
|
|
||||||
// fVideoView->ResizeTo(max_video_width - 1, max_video_height - 1);
|
|
||||||
ResizeVideoView(0, y, max_video_width, max_video_height);
|
|
||||||
if (fVideoView->IsHidden())
|
|
||||||
fVideoView->Show();
|
|
||||||
y += max_video_height;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (no_controls) {
|
|
||||||
if (!fControls->IsHidden())
|
|
||||||
fControls->Hide();
|
|
||||||
} else {
|
|
||||||
fControls->MoveTo(0, y);
|
|
||||||
fControls->ResizeTo(new_width, fControlsHeight - 1);
|
|
||||||
if (fControls->IsHidden())
|
|
||||||
fControls->Show();
|
|
||||||
// y += fControlsHeight;
|
|
||||||
}
|
}
|
||||||
|
ResizeTo(Bounds().Width(), height);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
printf("FrameResized leave\n");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
InfoWin::MessageReceived(BMessage *msg)
|
InfoWin::Update(uint32 which)
|
||||||
{
|
{
|
||||||
uint32 which;
|
printf("InfoWin::Update(0x%08lx)\n", which);
|
||||||
switch (msg->what) {
|
fLabelsView->SetText("");
|
||||||
case M_UPDATE_INFO:
|
fContentsView->SetText("");
|
||||||
if (msg->FindInt32("which", (int32 *)&which) < B_OK)
|
fLabelsView->SetFontAndColor(be_plain_font, B_FONT_ALL, &kBlue);
|
||||||
which = INFO_ALL;
|
fLabelsView->Insert("\n");
|
||||||
Update(which);
|
fContentsView->SetFontAndColor(be_plain_font, B_FONT_ALL);
|
||||||
break;
|
fContentsView->Insert("\n");
|
||||||
default:
|
|
||||||
BWindow::MessageReceived(msg);
|
fLabelsView->SetFontAndColor(be_plain_font, B_FONT_ALL, &kRed);
|
||||||
break;
|
|
||||||
|
status_t err;
|
||||||
|
// video track format information
|
||||||
|
if ((which & INFO_VIDEO) && fController->VideoTrackCount() > 0) {
|
||||||
|
fLabelsView->Insert("Video\n\n\n");
|
||||||
|
BString s;
|
||||||
|
media_format format;
|
||||||
|
media_raw_video_format videoFormat;
|
||||||
|
err = fController->GetEncodedVideoFormat(&format);
|
||||||
|
if (err < B_OK) {
|
||||||
|
s << "(" << strerror(err) << ")";
|
||||||
|
} else if (format.type == B_MEDIA_ENCODED_VIDEO) {
|
||||||
|
videoFormat = format.u.encoded_video.output;
|
||||||
|
media_codec_info mci;
|
||||||
|
err = fController->GetVideoCodecInfo(&mci);
|
||||||
|
if (err < B_OK)
|
||||||
|
s << "(" << strerror(err) << ")";
|
||||||
|
else
|
||||||
|
s << mci.pretty_name; //<< "(" << mci.short_name << ")";
|
||||||
|
} else if (format.type == B_MEDIA_RAW_VIDEO) {
|
||||||
|
videoFormat = format.u.raw_video;
|
||||||
|
s << "raw video";
|
||||||
|
} else
|
||||||
|
s << "unknown format";
|
||||||
|
s << "\n";
|
||||||
|
s << format.Width() << " x " << format.Height();
|
||||||
|
// encoded has output as 1st field...
|
||||||
|
s << ", " << videoFormat.field_rate << " fps";
|
||||||
|
s << "\n\n";
|
||||||
|
fContentsView->Insert(s.String());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// audio track format information
|
||||||
|
if ((which & INFO_AUDIO) && fController->AudioTrackCount() > 0) {
|
||||||
|
fLabelsView->Insert("Audio\n\n\n");
|
||||||
|
BString s;
|
||||||
|
media_format format;
|
||||||
|
media_raw_audio_format audioFormat;
|
||||||
|
err = fController->GetEncodedAudioFormat(&format);
|
||||||
|
//string_for_format(format, buf, sizeof(buf));
|
||||||
|
//printf("%s\n", buf);
|
||||||
|
if (err < 0) {
|
||||||
|
s << "(" << strerror(err) << ")";
|
||||||
|
} else if (format.type == B_MEDIA_ENCODED_AUDIO) {
|
||||||
|
audioFormat = format.u.encoded_audio.output;
|
||||||
|
media_codec_info mci;
|
||||||
|
err = fController->GetAudioCodecInfo(&mci);
|
||||||
|
if (err < 0)
|
||||||
|
s << "(" << strerror(err) << ")";
|
||||||
|
else
|
||||||
|
s << mci.pretty_name; //<< "(" << mci.short_name << ")";
|
||||||
|
} else if (format.type == B_MEDIA_RAW_AUDIO) {
|
||||||
|
audioFormat = format.u.raw_audio;
|
||||||
|
s << "raw audio";
|
||||||
|
} else
|
||||||
|
s << "unknown format";
|
||||||
|
s << "\n";
|
||||||
|
uint32 bitsPerSample = 8 * (audioFormat.format
|
||||||
|
& media_raw_audio_format::B_AUDIO_SIZE_MASK);
|
||||||
|
uint32 channelCount = audioFormat.channel_count;
|
||||||
|
float sr = audioFormat.frame_rate;
|
||||||
|
|
||||||
|
if (bitsPerSample > 0)
|
||||||
|
s << bitsPerSample << " Bit ";
|
||||||
|
if (channelCount == 1)
|
||||||
|
s << "Mono";
|
||||||
|
else if (channelCount == 2)
|
||||||
|
s << "Stereo";
|
||||||
|
else
|
||||||
|
s << channelCount << "Channels";
|
||||||
|
s << ", ";
|
||||||
|
if (sr > 0.0)
|
||||||
|
s << sr / 1000;
|
||||||
|
else
|
||||||
|
s << "??";
|
||||||
|
s<< " kHz";
|
||||||
|
s << "\n\n";
|
||||||
|
fContentsView->Insert(s.String());
|
||||||
|
}
|
||||||
|
|
||||||
|
// statistics
|
||||||
|
if ((which & INFO_STATS) && fController->HasFile()) {
|
||||||
|
fLabelsView->Insert("Duration\n\n");
|
||||||
|
BString s;
|
||||||
|
bigtime_t d = fController->Duration();
|
||||||
|
bigtime_t v;
|
||||||
|
|
||||||
|
//s << d << "µs; ";
|
||||||
|
|
||||||
|
d /= 1000;
|
||||||
|
|
||||||
|
v = d / (3600 * 1000);
|
||||||
|
d = d % (3600 * 1000);
|
||||||
|
bool hours = v > 0;
|
||||||
|
if (hours)
|
||||||
|
s << v << ":";
|
||||||
|
v = d / (60 * 1000);
|
||||||
|
d = d % (60 * 1000);
|
||||||
|
s << v << ":";
|
||||||
|
v = d / 1000;
|
||||||
|
s << v;
|
||||||
|
if (hours)
|
||||||
|
s << " h";
|
||||||
|
else
|
||||||
|
s << " min";
|
||||||
|
s << "\n\n";
|
||||||
|
fContentsView->Insert(s.String());
|
||||||
|
// TODO: demux/video/audio/... perfs (Kb/s)
|
||||||
|
}
|
||||||
|
|
||||||
|
if (which & INFO_TRANSPORT) {
|
||||||
|
// what is "Transport"?
|
||||||
|
}
|
||||||
|
|
||||||
|
if (which & INFO_FILE) {
|
||||||
|
if (fController->HasFile()) {
|
||||||
|
media_file_format ff;
|
||||||
|
BString s;
|
||||||
|
if (fController->GetFileFormatInfo(&ff) == B_OK) {
|
||||||
|
fLabelsView->Insert("Container\n\n");
|
||||||
|
s << ff.pretty_name;
|
||||||
|
s << "\n\n";
|
||||||
|
fContentsView->Insert(s.String());
|
||||||
|
} else
|
||||||
|
fContentsView->Insert("\n\n");
|
||||||
|
fLabelsView->Insert("Location\n");
|
||||||
|
if (fController->GetLocation(&s) < B_OK)
|
||||||
|
s = "<unknown>";
|
||||||
|
s << "\n";
|
||||||
|
fContentsView->Insert(s.String());
|
||||||
|
if (fController->GetName(&s) < B_OK)
|
||||||
|
s = "<unnamed media>";
|
||||||
|
fFilenameView->SetText(s.String());
|
||||||
|
} else {
|
||||||
|
fFilenameView->SetText("<no media>");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((which & INFO_COPYRIGHT) && fController->HasFile()) {
|
||||||
|
|
||||||
|
BString s;
|
||||||
|
if (fController->GetCopyright(&s) == B_OK && s.Length() > 0) {
|
||||||
|
fLabelsView->Insert("Copyright\n\n");
|
||||||
|
s << "\n\n";
|
||||||
|
fContentsView->Insert(s.String());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fController->Unlock();
|
||||||
|
|
||||||
|
ResizeToPreferred();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -21,16 +21,12 @@
|
|||||||
#define __FILE_INFO_WIN_H
|
#define __FILE_INFO_WIN_H
|
||||||
|
|
||||||
#include <Window.h>
|
#include <Window.h>
|
||||||
#include <TextView.h>
|
|
||||||
#include <StringView.h>
|
|
||||||
|
|
||||||
|
|
||||||
class MainWin;
|
|
||||||
class Controller;
|
class Controller;
|
||||||
|
class ControllerObserver;
|
||||||
class InfoView;
|
class InfoView;
|
||||||
|
|
||||||
#define M_UPDATE_INFO 'upda'
|
|
||||||
|
|
||||||
#define INFO_STATS 0x00000001
|
#define INFO_STATS 0x00000001
|
||||||
#define INFO_TRANSPORT 0x00000002
|
#define INFO_TRANSPORT 0x00000002
|
||||||
#define INFO_FILE 0x00000004
|
#define INFO_FILE 0x00000004
|
||||||
@@ -53,16 +49,16 @@ public:
|
|||||||
virtual void Pulse();
|
virtual void Pulse();
|
||||||
|
|
||||||
void ResizeToPreferred();
|
void ResizeToPreferred();
|
||||||
void Update(uint32 which=INFO_ALL); // threadsafe
|
void Update(uint32 which = INFO_ALL);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Controller* fController;
|
Controller* fController;
|
||||||
|
ControllerObserver* fControllerObserver;
|
||||||
|
|
||||||
InfoView* fInfoView;
|
InfoView* fInfoView;
|
||||||
BStringView* fFilenameView;
|
BStringView* fFilenameView;
|
||||||
BTextView* fLabelsView;
|
BTextView* fLabelsView;
|
||||||
BTextView* fContentsView;
|
BTextView* fContentsView;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // __FILE_INFO_WIN_H
|
#endif // __FILE_INFO_WIN_H
|
||||||
|
|||||||
@@ -680,12 +680,6 @@ MainWin::ShowFileInfo()
|
|||||||
fInfoWin->Activate();
|
fInfoWin->Activate();
|
||||||
fInfoWin->Unlock();
|
fInfoWin->Unlock();
|
||||||
}
|
}
|
||||||
|
|
||||||
BMessenger msgr(fInfoWin);
|
|
||||||
BMessage m(M_UPDATE_INFO);
|
|
||||||
m.AddInt32("which", INFO_ALL);
|
|
||||||
msgr.SendMessage(&m);
|
|
||||||
msgr.SendMessage(B_WINDOW_ACTIVATED);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -8,7 +8,9 @@
|
|||||||
#ifndef AUDIO_SUPPLIER_H
|
#ifndef AUDIO_SUPPLIER_H
|
||||||
#define AUDIO_SUPPLIER_H
|
#define AUDIO_SUPPLIER_H
|
||||||
|
|
||||||
|
|
||||||
#include <MediaDefs.h>
|
#include <MediaDefs.h>
|
||||||
|
#include <MediaFormats.h>
|
||||||
|
|
||||||
class AudioSupplier {
|
class AudioSupplier {
|
||||||
public:
|
public:
|
||||||
@@ -16,6 +18,10 @@ class AudioSupplier {
|
|||||||
virtual ~AudioSupplier();
|
virtual ~AudioSupplier();
|
||||||
|
|
||||||
virtual media_format Format() const = 0;
|
virtual media_format Format() const = 0;
|
||||||
|
virtual status_t GetEncodedFormat(media_format* format)
|
||||||
|
const = 0;
|
||||||
|
virtual status_t GetCodecInfo(media_codec_info* info) const = 0;
|
||||||
|
|
||||||
virtual status_t ReadFrames(void* buffer, int64* framesRead,
|
virtual status_t ReadFrames(void* buffer, int64* framesRead,
|
||||||
bigtime_t* performanceTime) = 0;
|
bigtime_t* performanceTime) = 0;
|
||||||
virtual status_t SeekToTime(bigtime_t* performanceTime) = 0;
|
virtual status_t SeekToTime(bigtime_t* performanceTime) = 0;
|
||||||
|
|||||||
@@ -62,6 +62,24 @@ MediaTrackAudioSupplier::Format() const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
status_t
|
||||||
|
MediaTrackAudioSupplier::GetEncodedFormat(media_format* format) const
|
||||||
|
{
|
||||||
|
if (!fMediaTrack)
|
||||||
|
return B_NO_INIT;
|
||||||
|
return fMediaTrack->EncodedFormat(format);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
status_t
|
||||||
|
MediaTrackAudioSupplier::GetCodecInfo(media_codec_info* info) const
|
||||||
|
{
|
||||||
|
if (!fMediaTrack)
|
||||||
|
return B_NO_INIT;
|
||||||
|
return fMediaTrack->GetCodecInfo(info);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
status_t
|
status_t
|
||||||
MediaTrackAudioSupplier::ReadFrames(void* buffer, int64* framesRead,
|
MediaTrackAudioSupplier::ReadFrames(void* buffer, int64* framesRead,
|
||||||
bigtime_t* performanceTime)
|
bigtime_t* performanceTime)
|
||||||
@@ -75,6 +93,14 @@ MediaTrackAudioSupplier::ReadFrames(void* buffer, int64* framesRead,
|
|||||||
status_t ret = fMediaTrack->ReadFrames(buffer, framesRead, &mediaHeader);
|
status_t ret = fMediaTrack->ReadFrames(buffer, framesRead, &mediaHeader);
|
||||||
|
|
||||||
if (ret < B_OK) {
|
if (ret < B_OK) {
|
||||||
|
// further analyse the error
|
||||||
|
if (fDuration == 0 || (double)fPerformanceTime / fDuration > 0.95) {
|
||||||
|
// some codecs don't behave well, or maybe somes files are bad,
|
||||||
|
// they don't report the end of the stream correctly
|
||||||
|
// NOTE: "more than 95% of the stream" is of course pure guess,
|
||||||
|
// but it fixed the problem I had with some files
|
||||||
|
ret = B_LAST_BUFFER_ERROR;
|
||||||
|
}
|
||||||
printf("MediaTrackAudioSupplier::ReadFrame() - "
|
printf("MediaTrackAudioSupplier::ReadFrame() - "
|
||||||
"error while reading frames: %s\n", strerror(ret));
|
"error while reading frames: %s\n", strerror(ret));
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -18,6 +18,9 @@ class MediaTrackAudioSupplier : public AudioSupplier {
|
|||||||
virtual ~MediaTrackAudioSupplier();
|
virtual ~MediaTrackAudioSupplier();
|
||||||
|
|
||||||
virtual media_format Format() const;
|
virtual media_format Format() const;
|
||||||
|
virtual status_t GetEncodedFormat(media_format* format) const;
|
||||||
|
virtual status_t GetCodecInfo(media_codec_info* info) const;
|
||||||
|
|
||||||
virtual status_t ReadFrames(void* buffer, int64* framesRead,
|
virtual status_t ReadFrames(void* buffer, int64* framesRead,
|
||||||
bigtime_t* performanceTime);
|
bigtime_t* performanceTime);
|
||||||
virtual status_t SeekToTime(bigtime_t* performanceTime);
|
virtual status_t SeekToTime(bigtime_t* performanceTime);
|
||||||
|
|||||||
@@ -120,6 +120,24 @@ MediaTrackVideoSupplier::Format() const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
status_t
|
||||||
|
MediaTrackVideoSupplier::GetEncodedFormat(media_format* format) const
|
||||||
|
{
|
||||||
|
if (!fVideoTrack)
|
||||||
|
return B_NO_INIT;
|
||||||
|
return fVideoTrack->EncodedFormat(format);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
status_t
|
||||||
|
MediaTrackVideoSupplier::GetCodecInfo(media_codec_info* info) const
|
||||||
|
{
|
||||||
|
if (!fVideoTrack)
|
||||||
|
return B_NO_INIT;
|
||||||
|
return fVideoTrack->GetCodecInfo(info);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
status_t
|
status_t
|
||||||
MediaTrackVideoSupplier::ReadFrame(void* buffer, bigtime_t* performanceTime)
|
MediaTrackVideoSupplier::ReadFrame(void* buffer, bigtime_t* performanceTime)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -19,6 +19,9 @@ class MediaTrackVideoSupplier : public VideoSupplier {
|
|||||||
virtual ~MediaTrackVideoSupplier();
|
virtual ~MediaTrackVideoSupplier();
|
||||||
|
|
||||||
virtual media_format Format() const;
|
virtual media_format Format() const;
|
||||||
|
virtual status_t GetEncodedFormat(media_format* format) const;
|
||||||
|
virtual status_t GetCodecInfo(media_codec_info* info) const;
|
||||||
|
|
||||||
virtual status_t ReadFrame(void* buffer,
|
virtual status_t ReadFrame(void* buffer,
|
||||||
bigtime_t* performanceTime);
|
bigtime_t* performanceTime);
|
||||||
virtual status_t SeekToTime(bigtime_t* performanceTime);
|
virtual status_t SeekToTime(bigtime_t* performanceTime);
|
||||||
|
|||||||
@@ -8,7 +8,9 @@
|
|||||||
#ifndef VIDEO_SUPPLIER_H
|
#ifndef VIDEO_SUPPLIER_H
|
||||||
#define VIDEO_SUPPLIER_H
|
#define VIDEO_SUPPLIER_H
|
||||||
|
|
||||||
|
|
||||||
#include <MediaDefs.h>
|
#include <MediaDefs.h>
|
||||||
|
#include <MediaFormats.h>
|
||||||
|
|
||||||
class VideoSupplier {
|
class VideoSupplier {
|
||||||
public:
|
public:
|
||||||
@@ -16,6 +18,9 @@ class VideoSupplier {
|
|||||||
virtual ~VideoSupplier();
|
virtual ~VideoSupplier();
|
||||||
|
|
||||||
virtual media_format Format() const = 0;
|
virtual media_format Format() const = 0;
|
||||||
|
virtual status_t GetEncodedFormat(media_format* format)
|
||||||
|
const = 0;
|
||||||
|
virtual status_t GetCodecInfo(media_codec_info* info) const = 0;
|
||||||
virtual status_t ReadFrame(void* buffer,
|
virtual status_t ReadFrame(void* buffer,
|
||||||
bigtime_t* performanceTime) = 0;
|
bigtime_t* performanceTime) = 0;
|
||||||
virtual status_t SeekToTime(bigtime_t* performanceTime) = 0;
|
virtual status_t SeekToTime(bigtime_t* performanceTime) = 0;
|
||||||
|
|||||||
Reference in New Issue
Block a user