- Implemented MediaExtractor::Copyright, which just calls the instantiated reader

- Implemented BMediaFile::Copyright, which just calls Copyright() of the extractor. So this is just a simple pass through.
- Style cleanup (mostly whitespaces)

Problem is that our readers currently return the copyright of the source code, not the copyright of the MediaFile itself, like the BeBook documents. Thus, we might need to change all readers to return appropiate data or behave differently for Haiku readers.



git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@25356 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Maurice Kalinowski 2008-05-07 21:09:56 +00:00
parent 3db71143ea
commit 8b1e3b1af8
3 changed files with 48 additions and 38 deletions

View File

@ -27,11 +27,13 @@ public:
~MediaExtractor();
status_t InitCheck();
void GetFileFormatInfo(media_file_format *mfi) const;
int32 StreamCount();
const char* Copyright();
const media_format * EncodedFormat(int32 stream);
int64 CountFrames(int32 stream) const;
bigtime_t Duration(int32 stream) const;
@ -40,12 +42,13 @@ public:
int64 *frame, bigtime_t *time);
status_t FindKeyFrame(int32 stream, uint32 seekTo,
int64 *frame, bigtime_t *time) const;
status_t GetNextChunk(int32 stream,
const void **chunkBuffer, size_t *chunkSize,
media_header *mediaHeader);
status_t CreateDecoder(int32 stream, Decoder **decoder, media_codec_info *mci);
status_t CreateDecoder(int32 stream, Decoder **decoder,
media_codec_info *mci);
private:
static int32 extractor_thread(void *arg);
@ -53,14 +56,14 @@ private:
private:
status_t fErr;
sem_id fExtractorWaitSem;
thread_id fExtractorThread;
volatile bool fTerminateExtractor;
BDataIO *fSource;
Reader *fReader;
stream_info * fStreamInfo;
int32 fStreamCount;

View File

@ -1,5 +1,6 @@
/*
/*
** Copyright 2004-2007, Marcus Overhagen. All rights reserved.
** Copyright 2008, Maurice Kalinowski. All rights reserved.
** Distributed under the terms of the MIT License.
*/
#include "MediaExtractor.h"
@ -71,7 +72,7 @@ MediaExtractor::MediaExtractor(BDataIO *source, int32 flags)
"stream %ld failed\n", i);
}
}
#if DISABLE_CHUNK_CACHE == 0
// start extractor thread
fExtractorWaitSem = create_sem(1, "media extractor thread sem");
@ -85,7 +86,7 @@ MediaExtractor::MediaExtractor(BDataIO *source, int32 flags)
MediaExtractor::~MediaExtractor()
{
CALLED();
// terminate extractor thread
fTerminateExtractor = true;
release_sem(fExtractorWaitSem);
@ -132,6 +133,13 @@ MediaExtractor::StreamCount()
}
const char*
MediaExtractor::Copyright()
{
return fReader->Copyright();
}
const media_format *
MediaExtractor::EncodedFormat(int32 stream)
{
@ -148,7 +156,7 @@ MediaExtractor::CountFrames(int32 stream) const
media_format format;
const void *infoBuffer;
size_t infoSize;
fReader->GetStreamInfo(fStreamInfo[stream].cookie, &frameCount, &duration,
&format, &infoBuffer, &infoSize);
@ -165,7 +173,7 @@ MediaExtractor::Duration(int32 stream) const
media_format format;
const void *infoBuffer;
size_t infoSize;
fReader->GetStreamInfo(fStreamInfo[stream].cookie, &frameCount, &duration,
&format, &infoBuffer, &infoSize);
@ -180,16 +188,16 @@ MediaExtractor::Seek(int32 stream, uint32 seekTo,
CALLED();
if (fStreamInfo[stream].status != B_OK)
return fStreamInfo[stream].status;
status_t result;
result = fReader->Seek(fStreamInfo[stream].cookie, seekTo, frame, time);
if (result != B_OK)
return result;
// clear buffered chunks
fStreamInfo[stream].chunkCache->MakeEmpty();
release_sem(fExtractorWaitSem);
return B_OK;
}
@ -201,7 +209,7 @@ MediaExtractor::FindKeyFrame(int32 stream, uint32 seekTo, int64 *frame,
CALLED();
if (fStreamInfo[stream].status != B_OK)
return fStreamInfo[stream].status;
return fReader->FindKeyFrame(fStreamInfo[stream].cookie,
seekTo, frame, time);
}
@ -219,7 +227,7 @@ MediaExtractor::GetNextChunk(int32 stream,
static BLocker locker;
BAutolock lock(locker);
return fReader->GetNextChunk(fStreamInfo[stream].cookie, chunkBuffer,
chunkSize, mediaHeader);
chunkSize, mediaHeader);
#endif
status_t err;
@ -240,7 +248,7 @@ public:
fExtractor = extractor;
fStream = stream;
}
virtual status_t GetNextChunk(const void **chunkBuffer, size_t *chunkSize,
media_header *mediaHeader)
{
@ -264,7 +272,7 @@ MediaExtractor::CreateDecoder(int32 stream, Decoder **out_decoder,
"stream %ld\n", stream);
return res;
}
res = _plugin_manager.CreateDecoder(&decoder,
fStreamInfo[stream].encodedFormat);
if (res != B_OK) {
@ -283,7 +291,7 @@ MediaExtractor::CreateDecoder(int32 stream, Decoder **out_decoder,
}
decoder->SetChunkProvider(chunkProvider);
res = decoder->Setup(&fStreamInfo[stream].encodedFormat,
fStreamInfo[stream].infoBuffer, fStreamInfo[stream].infoBufferSize);
if (res != B_OK) {
@ -321,7 +329,7 @@ MediaExtractor::ExtractorThread()
acquire_sem(fExtractorWaitSem);
if (fTerminateExtractor)
return;
bool refill_done;
do {
refill_done = false;

View File

@ -12,7 +12,7 @@
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
@ -82,7 +82,7 @@ BMediaFile::BMediaFile(const entry_ref *ref,
InitWriter(new BFile(ref, O_WRONLY), mfi, flags);
}
BMediaFile::BMediaFile(BDataIO *destination,
const media_file_format * mfi,
int32 flags)
@ -121,7 +121,7 @@ BMediaFile::SetTo(BDataIO *destination)
BMediaFile::~BMediaFile()
{
CALLED();
ReleaseAllTracks();
delete[] fTrackList;
delete fExtractor;
@ -130,7 +130,7 @@ BMediaFile::~BMediaFile()
}
status_t
status_t
BMediaFile::InitCheck() const
{
CALLED();
@ -139,7 +139,7 @@ BMediaFile::InitCheck() const
// Get info about the underlying file format.
status_t
status_t
BMediaFile::GetFileFormatInfo(media_file_format *mfi) const
{
CALLED();
@ -153,8 +153,7 @@ BMediaFile::GetFileFormatInfo(media_file_format *mfi) const
const char *
BMediaFile::Copyright(void) const
{
UNIMPLEMENTED();
return "";
return fExtractor->Copyright();
}
@ -205,7 +204,7 @@ BMediaFile::ReleaseTrack(BMediaTrack *track)
}
status_t
status_t
BMediaFile::ReleaseAllTracks(void)
{
CALLED();
@ -224,7 +223,7 @@ BMediaFile::ReleaseAllTracks(void)
// Create and add a track to the media file
BMediaTrack *
BMediaFile::CreateTrack(media_format *mf,
BMediaFile::CreateTrack(media_format *mf,
const media_codec_info *mci,
uint32 flags)
{
@ -244,7 +243,7 @@ BMediaFile::CreateTrack(media_format *mf, uint32 flags)
// For BeOS R5 compatibility
extern "C" BMediaTrack * CreateTrack__10BMediaFileP12media_formatPC16media_codec_info(
BMediaFile *self, media_format *mf, const media_codec_info *mci);
BMediaTrack *
BMediaTrack *
CreateTrack__10BMediaFileP12media_formatPC16media_codec_info(
BMediaFile *self,
media_format *mf,
@ -257,7 +256,7 @@ CreateTrack__10BMediaFileP12media_formatPC16media_codec_info(
// For BeOS R5 compatibility
extern "C" BMediaTrack * CreateTrack__10BMediaFileP12media_format(
BMediaFile *self, media_format *mf);
BMediaTrack *
BMediaTrack *
CreateTrack__10BMediaFileP12media_format(
BMediaFile *self,
media_format *mf)
@ -345,7 +344,7 @@ BMediaFile::GetParameterView()
}
/* virtual */ status_t
/* virtual */ status_t
BMediaFile::Perform(int32 selector, void * data)
{
UNIMPLEMENTED();
@ -366,7 +365,7 @@ BMediaFile::ControlFile(int32 selector, void * io_data, size_t size)
*************************************************************/
void
void
BMediaFile::Init()
{
CALLED();
@ -386,18 +385,18 @@ BMediaFile::Init()
}
void
void
BMediaFile::InitReader(BDataIO *source, int32 flags)
{
CALLED();
fSource = source;
fExtractor = new MediaExtractor(source, flags);
fErr = fExtractor->InitCheck();
if (fErr)
return;
fExtractor->GetFileFormatInfo(&fMFI);
fTrackNum = fExtractor->StreamCount();
fTrackList = new BMediaTrack *[fTrackNum];