2 * Copyright 2002-2007, Marcus Overhagen <marcus@overhagen.de>
3 * Copyright 2009-2010, Stephan Aßmus <superstippi@gmx.de>
4 * Copyright 2013, Haiku, Inc. All Rights Reserved.
5 * All rights reserved. Distributed under the terms of the MIT license.
8 * Stephan Aßmus, superstippi@gmx.de
9 * Marcus Overhagen, marcus@overhagen.de
13 #include <MediaTrack.h>
23 #include "MediaExtractor.h"
24 #include "MediaWriter.h"
25 #include "PluginManager.h"
28 //#define TRACE_MEDIA_TRACK
29 #ifdef TRACE_MEDIA_TRACK
39 #define ERROR(a...) fprintf(stderr, a)
42 #define CONVERT_TO_INT32 0
43 // TODO: Test! This triggers a few bugs!
45 // flags used for workarounds
47 FORCE_RAW_AUDIO
= 0x0001,
48 FORCE_RAW_VIDEO
= 0x0002,
49 FORCE_RAW_AUDIO_INT16_FORMAT
= 0x0010,
50 FORCE_RAW_AUDIO_INT32_FORMAT
= 0x0020,
51 FORCE_RAW_AUDIO_FLOAT_FORMAT
= 0x0040,
52 FORCE_RAW_AUDIO_HOST_ENDIAN
= 0x0100,
53 IGNORE_ENCODED_AUDIO
= 0x1000,
54 IGNORE_ENCODED_VIDEO
= 0x2000,
57 #define B_MEDIA_DISABLE_FORMAT_TRANSLATION 0x4000
58 // TODO: move this (after name change?) to MediaDefs.h
61 class RawDecoderChunkProvider
: public ChunkProvider
{
63 RawDecoderChunkProvider(Decoder
* decoder
,
64 int buffer_size
, int frame_size
);
65 virtual ~RawDecoderChunkProvider();
67 status_t
GetNextChunk(const void** chunkBuffer
,
69 media_header
* mediaHeader
);
79 /*************************************************************
80 * protected BMediaTrack
81 *************************************************************/
83 BMediaTrack::~BMediaTrack()
87 gPluginManager
.DestroyDecoder(fRawDecoder
);
88 gPluginManager
.DestroyDecoder(fDecoder
);
89 gPluginManager
.DestroyEncoder(fEncoder
);
92 /*************************************************************
94 *************************************************************/
97 BMediaTrack::InitCheck() const
106 BMediaTrack::GetCodecInfo(media_codec_info
* _codecInfo
) const
110 if (fDecoder
== NULL
)
113 *_codecInfo
= fCodecInfo
;
114 strlcpy(_codecInfo
->pretty_name
, fCodecInfo
.pretty_name
,
115 sizeof(_codecInfo
->pretty_name
));
122 BMediaTrack::EncodedFormat(media_format
* _format
) const
129 if (fExtractor
== NULL
)
132 *_format
= *fExtractor
->EncodedFormat(fStream
);
134 #ifdef TRACE_MEDIA_TRACK
136 string_for_format(*_format
, s
, sizeof(s
));
137 printf("BMediaTrack::EncodedFormat: %s\n", s
);
144 // for BeOS R5 compatibility
145 extern "C" status_t
DecodedFormat__11BMediaTrackP12media_format(
146 BMediaTrack
* self
, media_format
* _format
);
148 status_t
DecodedFormat__11BMediaTrackP12media_format(BMediaTrack
* self
,
149 media_format
* _format
)
151 return self
->DecodedFormat(_format
, 0);
156 BMediaTrack::DecodedFormat(media_format
* _format
, uint32 flags
)
163 if (fExtractor
== NULL
|| fDecoder
== NULL
)
166 gPluginManager
.DestroyDecoder(fRawDecoder
);
169 #ifdef TRACE_MEDIA_TRACK
171 string_for_format(*_format
, s
, sizeof(s
));
172 printf("BMediaTrack::DecodedFormat: req1: %s\n", s
);
175 if ((fWorkaroundFlags
& FORCE_RAW_AUDIO
)
176 || ((fWorkaroundFlags
& IGNORE_ENCODED_AUDIO
)
177 && _format
->type
== B_MEDIA_ENCODED_AUDIO
)) {
178 _format
->type
= B_MEDIA_RAW_AUDIO
;
179 _format
->u
.raw_audio
= media_multi_audio_format::wildcard
;
181 if ((fWorkaroundFlags
& FORCE_RAW_VIDEO
)
182 || ((fWorkaroundFlags
& IGNORE_ENCODED_VIDEO
)
183 && _format
->type
== B_MEDIA_ENCODED_VIDEO
)) {
184 _format
->type
= B_MEDIA_RAW_VIDEO
;
185 _format
->u
.raw_video
= media_raw_video_format::wildcard
;
187 if (_format
->type
== B_MEDIA_RAW_AUDIO
) {
188 if (fWorkaroundFlags
& FORCE_RAW_AUDIO_HOST_ENDIAN
)
189 _format
->u
.raw_audio
.byte_order
= B_MEDIA_HOST_ENDIAN
;
191 if (fWorkaroundFlags
& FORCE_RAW_AUDIO_INT16_FORMAT
) {
192 _format
->u
.raw_audio
.format
193 = media_raw_audio_format::B_AUDIO_SHORT
;
195 if (fWorkaroundFlags
& FORCE_RAW_AUDIO_INT32_FORMAT
) {
196 _format
->u
.raw_audio
.format
197 = media_raw_audio_format::B_AUDIO_INT
;
199 if (fWorkaroundFlags
& FORCE_RAW_AUDIO_FLOAT_FORMAT
) {
200 _format
->u
.raw_audio
.format
201 = media_raw_audio_format::B_AUDIO_FLOAT
;
205 #ifdef TRACE_MEDIA_TRACK
206 string_for_format(*_format
, s
, sizeof(s
));
207 printf("BMediaTrack::DecodedFormat: req2: %s\n", s
);
211 status_t result
= fDecoder
->NegotiateOutputFormat(_format
);
213 #ifdef TRACE_MEDIA_TRACK
214 string_for_format(*_format
, s
, sizeof(s
));
215 printf("BMediaTrack::DecodedFormat: nego: %s\n", s
);
218 if (_format
->type
== 0) {
219 #ifdef TRACE_MEDIA_TRACK
220 printf("BMediaTrack::DecodedFormat: Decoder didn't set output format "
225 if (_format
->type
== B_MEDIA_RAW_AUDIO
) {
226 if (_format
->u
.raw_audio
.byte_order
== 0) {
227 #ifdef TRACE_MEDIA_TRACK
228 printf("BMediaTrack::DecodedFormat: Decoder didn't set raw audio "
229 "output byte order.\n");
232 if (_format
->u
.raw_audio
.format
== 0) {
233 #ifdef TRACE_MEDIA_TRACK
234 printf("BMediaTrack::DecodedFormat: Decoder didn't set raw audio "
235 "output sample format.\n");
238 if (_format
->u
.raw_audio
.buffer_size
<= 0) {
239 #ifdef TRACE_MEDIA_TRACK
240 printf("BMediaTrack::DecodedFormat: Decoder didn't set raw audio "
241 "output buffer size.\n");
246 if (_format
->type
== B_MEDIA_RAW_VIDEO
) {
247 if (_format
->u
.raw_video
.display
.format
== 0) {
248 #ifdef TRACE_MEDIA_TRACK
249 printf("BMediaTrack::DecodedFormat: Decoder didn't set raw video "
250 "output color space.\n");
253 if (_format
->u
.raw_video
.display
.line_width
== 0) {
254 #ifdef TRACE_MEDIA_TRACK
255 printf("BMediaTrack::DecodedFormat: Decoder didn't set raw video "
256 "output line_width.\n");
259 if (_format
->u
.raw_video
.display
.line_count
== 0) {
260 #ifdef TRACE_MEDIA_TRACK
261 printf("BMediaTrack::DecodedFormat: Decoder didn't set raw video "
262 "output line_count.\n");
265 if (_format
->u
.raw_video
.display
.bytes_per_row
== 0) {
266 #ifdef TRACE_MEDIA_TRACK
267 printf("BMediaTrack::DecodedFormat: Decoder didn't set raw video "
268 "output bytes_per_row.\n");
273 if ((flags
& B_MEDIA_DISABLE_FORMAT_TRANSLATION
) == 0) {
274 if (fFormat
.type
== B_MEDIA_RAW_AUDIO
275 && _format
->type
== B_MEDIA_RAW_AUDIO
276 && fFormat
.u
.raw_audio
.format
!= 0
277 && fFormat
.u
.raw_audio
.format
!= _format
->u
.raw_audio
.format
) {
278 if (SetupFormatTranslation(*_format
, &fFormat
))
285 // string_for_format(*_format, s, sizeof(s));
286 // printf("BMediaTrack::DecodedFormat: status: %s\n", s);
292 BMediaTrack::GetMetaData(BMessage
* _data
) const
296 if (fExtractor
== NULL
)
304 return fExtractor
->GetStreamMetaData(fStream
, _data
);
309 BMediaTrack::CountFrames() const
313 int64 frames
= fExtractor
? fExtractor
->CountFrames(fStream
) : 0;
314 // printf("BMediaTrack::CountFrames: %lld\n", frames);
320 BMediaTrack::Duration() const
324 bigtime_t duration
= fExtractor
? fExtractor
->Duration(fStream
) : 0;
325 // printf("BMediaTrack::Duration: %lld\n", duration);
331 BMediaTrack::CurrentFrame() const
333 return fCurrentFrame
;
338 BMediaTrack::CurrentTime() const
343 // BMediaTrack::ReadFrames(char*, long long*, media_header*)
344 // Compatibility for R5 and below. Required by Corum III and Civ:CTP.
348 ReadFrames__11BMediaTrackPcPxP12media_header(BMediaTrack
* self
,
349 char* _buffer
, int64
* _frameCount
, media_header
* header
)
351 return self
->ReadFrames(_buffer
, _frameCount
, header
, 0);
354 #endif // __GNUC__ < 3
357 BMediaTrack::ReadFrames(void* buffer
, int64
* _frameCount
, media_header
* header
)
359 return ReadFrames(buffer
, _frameCount
, header
, NULL
);
364 BMediaTrack::ReadFrames(void* buffer
, int64
* _frameCount
,
365 media_header
* _header
, media_decode_info
* info
)
369 if (fDecoder
== NULL
)
372 if (buffer
== NULL
|| _frameCount
== NULL
)
379 // Always clear the header first, as the decoder may not set all fields.
380 memset(_header
, 0, sizeof(media_header
));
382 status_t result
= fRawDecoder
!= NULL
383 ? fRawDecoder
->Decode(buffer
, _frameCount
, _header
, info
)
384 : fDecoder
->Decode(buffer
, _frameCount
, _header
, info
);
386 if (result
== B_OK
) {
387 fCurrentFrame
+= *_frameCount
;
388 bigtime_t framesDuration
= (bigtime_t
)(*_frameCount
* 1000000
390 fCurrentTime
= _header
->start_time
+ framesDuration
;
392 // This debug output shows drift between calculated fCurrentFrame and
393 // time-based current frame, if there is any.
394 if (fFormat
.type
== B_MEDIA_RAW_AUDIO
) {
395 printf("current frame: %lld / calculated: %lld (%.2f/%.2f)\r",
397 int64(fCurrentTime
* _FrameRate() / 1000000.0 + 0.5),
398 fCurrentTime
/ 1000000.0, (float)fCurrentFrame
/ _FrameRate());
403 ERROR("BMediaTrack::ReadFrames: decoder returned error %#" B_PRIx32
404 " (%s)\n", result
, strerror(result
));
409 PRINT(1, "BMediaTrack::ReadFrames: stream %ld, start-time %5Ld.%06Ld, "
410 "%lld frames\n", fStream
, _header
->start_time
/ 1000000,
411 _header
->start_time
% 1000000, *out_frameCount
);
419 BMediaTrack::ReplaceFrames(const void* inBuffer
, int64
* _frameCount
,
420 const media_header
* header
)
424 // TODO: Actually, a file is either open for reading or writing at the
425 // moment. Since the chunk size of encoded media data will change,
426 // implementing this call will only be possible for raw media tracks.
428 return B_NOT_SUPPORTED
;
433 BMediaTrack::SeekToTime(bigtime_t
* _time
, int32 flags
)
437 if (fDecoder
== NULL
|| fExtractor
== NULL
)
443 // Make sure flags are valid
444 flags
= (flags
& B_MEDIA_SEEK_DIRECTION_MASK
) | B_MEDIA_SEEK_TO_TIME
;
447 bigtime_t requestedTime
= *_time
;
451 status_t result
= fExtractor
->Seek(fStream
, flags
, &frame
, _time
);
452 if (result
!= B_OK
) {
453 ERROR("BMediaTrack::SeekToTime: extractor seek failed\n");
457 result
= fDecoder
->SeekedTo(frame
, *_time
);
458 if (result
!= B_OK
) {
459 ERROR("BMediaTrack::SeekToTime: decoder seek failed\n");
463 if (fRawDecoder
!= NULL
) {
464 result
= fRawDecoder
->SeekedTo(frame
, *_time
);
465 if (result
!= B_OK
) {
466 ERROR("BMediaTrack::SeekToTime: raw decoder seek failed\n");
471 fCurrentFrame
= frame
;
472 fCurrentTime
= *_time
;
474 PRINT(1, "BMediaTrack::SeekToTime finished, requested %.6f, result %.6f\n",
475 requestedTime
/ 1000000.0, *_time
/ 1000000.0);
482 BMediaTrack::SeekToFrame(int64
* _frame
, int32 flags
)
486 if (fDecoder
== NULL
|| fExtractor
== NULL
)
492 // Make sure flags are valid
493 flags
= (flags
& B_MEDIA_SEEK_DIRECTION_MASK
) | B_MEDIA_SEEK_TO_FRAME
;
496 int64 requestedFrame
= *_frame
;
500 status_t result
= fExtractor
->Seek(fStream
, flags
, _frame
, &time
);
501 if (result
!= B_OK
) {
502 ERROR("BMediaTrack::SeekToFrame: extractor seek failed\n");
506 result
= fDecoder
->SeekedTo(*_frame
, time
);
507 if (result
!= B_OK
) {
508 ERROR("BMediaTrack::SeekToFrame: decoder seek failed\n");
512 if (fRawDecoder
!= NULL
) {
513 result
= fRawDecoder
->SeekedTo(*_frame
, time
);
514 if (result
!= B_OK
) {
515 ERROR("BMediaTrack::SeekToFrame: raw decoder seek failed\n");
520 fCurrentFrame
= *_frame
;
523 PRINT(1, "BMediaTrack::SeekToTime SeekToFrame, requested %lld, "
524 "result %lld\n", requestedFrame
, *_frame
);
531 BMediaTrack::FindKeyFrameForTime(bigtime_t
* _time
, int32 flags
) const
535 if (fExtractor
== NULL
)
541 // Make sure flags are valid
542 flags
= (flags
& B_MEDIA_SEEK_DIRECTION_MASK
) | B_MEDIA_SEEK_TO_TIME
;
545 // dummy frame, will be ignored because of flags
546 status_t result
= fExtractor
->FindKeyFrame(fStream
, flags
, &frame
, _time
);
547 if (result
!= B_OK
) {
548 ERROR("BMediaTrack::FindKeyFrameForTime: extractor seek failed: %s\n",
557 BMediaTrack::FindKeyFrameForFrame(int64
* _frame
, int32 flags
) const
561 if (fExtractor
== NULL
)
567 // Make sure flags are valid
568 flags
= (flags
& B_MEDIA_SEEK_DIRECTION_MASK
) | B_MEDIA_SEEK_TO_FRAME
;
571 // dummy time, will be ignored because of flags
572 status_t result
= fExtractor
->FindKeyFrame(fStream
, flags
, _frame
, &time
);
573 if (result
!= B_OK
) {
574 ERROR("BMediaTrack::FindKeyFrameForFrame: extractor seek failed: %s\n",
583 BMediaTrack::ReadChunk(char** _buffer
, int32
* _size
, media_header
* _header
)
587 if (fExtractor
== NULL
)
590 if (_buffer
== NULL
|| _size
== NULL
)
597 // Always clear the header first, as the extractor may not set all fields.
598 memset(_header
, 0, sizeof(media_header
));
602 status_t result
= fExtractor
->GetNextChunk(fStream
, &buffer
, &size
,
605 if (result
== B_OK
) {
606 *_buffer
= const_cast<char*>(static_cast<const char*>(buffer
));
607 // TODO: Change the pointer type when we break the API.
609 // TODO: This changes the meaning of fCurrentTime from pointing
610 // to the next chunk start time (i.e. after seeking) to the start time
611 // of the last chunk. Asking the extractor for the current time will
612 // not work so well because of the chunk cache. But providing a
613 // "duration" field in the media_header could be useful.
614 fCurrentTime
= _header
->start_time
;
615 fCurrentFrame
= (int64
)(fCurrentTime
* _FrameRate() / 1000000LL);
624 BMediaTrack::AddCopyright(const char* copyright
)
629 return fWriter
->SetCopyright(fStream
, copyright
);
634 BMediaTrack::AddTrackInfo(uint32 code
, const void* data
, size_t size
,
640 return fWriter
->AddTrackInfo(fStream
, code
, data
, size
, flags
);
645 BMediaTrack::WriteFrames(const void* data
, int32 frameCount
, int32 flags
)
647 media_encode_info encodeInfo
;
648 encodeInfo
.flags
= flags
;
650 return WriteFrames(data
, frameCount
, &encodeInfo
);
655 BMediaTrack::WriteFrames(const void* data
, int64 frameCount
,
656 media_encode_info
* info
)
658 if (fEncoder
== NULL
)
661 return fEncoder
->Encode(data
, frameCount
, info
);
666 BMediaTrack::WriteChunk(const void* data
, size_t size
, uint32 flags
)
668 media_encode_info encodeInfo
;
669 encodeInfo
.flags
= flags
;
671 return WriteChunk(data
, size
, &encodeInfo
);
676 BMediaTrack::WriteChunk(const void* data
, size_t size
, media_encode_info
* info
)
681 return fWriter
->WriteChunk(fStream
, data
, size
, info
);
691 return fWriter
->Flush();
695 // deprecated BeOS R5 API
700 if (GetParameterWeb(&web
) == B_OK
)
708 BMediaTrack::GetParameterWeb(BParameterWeb
** outWeb
)
713 if (fEncoder
== NULL
)
716 // TODO: This method is new in Haiku. The header mentions it returns a
717 // copy. But how could it even do that? How can one clone a web and make
718 // it point to the same BControllable?
719 *outWeb
= fEncoder
->ParameterWeb();
723 return B_NOT_SUPPORTED
;
728 BMediaTrack::GetParameterValue(int32 id
, void* value
, size_t* size
)
730 if (value
== NULL
|| size
== NULL
)
733 if (fEncoder
== NULL
)
736 return fEncoder
->GetParameterValue(id
, value
, size
);
741 BMediaTrack::SetParameterValue(int32 id
, const void* value
, size_t size
)
743 if (value
== NULL
|| size
== 0)
746 if (fEncoder
== NULL
)
749 return fEncoder
->SetParameterValue(id
, value
, size
);
754 BMediaTrack::GetParameterView()
756 if (fEncoder
== NULL
)
759 return fEncoder
->ParameterView();
764 BMediaTrack::GetQuality(float* quality
)
769 encode_parameters parameters
;
770 status_t result
= GetEncodeParameters(¶meters
);
774 *quality
= parameters
.quality
;
781 BMediaTrack::SetQuality(float quality
)
783 encode_parameters parameters
;
784 status_t result
= GetEncodeParameters(¶meters
);
794 parameters
.quality
= quality
;
796 return SetEncodeParameters(¶meters
);
801 BMediaTrack::GetEncodeParameters(encode_parameters
* parameters
) const
803 if (parameters
== NULL
)
806 if (fEncoder
== NULL
)
809 return fEncoder
->GetEncodeParameters(parameters
);
814 BMediaTrack::SetEncodeParameters(encode_parameters
* parameters
)
816 if (parameters
== NULL
)
819 if (fEncoder
== NULL
)
822 return fEncoder
->SetEncodeParameters(parameters
);
827 BMediaTrack::Perform(int32 selector
, void* data
)
832 // #pragma mark - private
835 BMediaTrack::BMediaTrack(BPrivate::media::MediaExtractor
* extractor
,
840 fWorkaroundFlags
= 0;
843 fExtractor
= extractor
;
849 status_t ret
= fExtractor
->CreateDecoder(fStream
, &fDecoder
, &fCodecInfo
);
851 TRACE("BMediaTrack::BMediaTrack: Error: creating decoder failed: "
852 "%s\n", strerror(ret
));
853 // We do not set fInitStatus here, because ReadChunk should still work.
867 BMediaTrack::BMediaTrack(BPrivate::media::MediaWriter
* writer
,
868 int32 streamIndex
, media_format
* format
,
869 const media_codec_info
* codecInfo
)
873 fWorkaroundFlags
= 0;
876 // TODO: Not yet sure what this was needed for...
878 fStream
= streamIndex
;
883 if (codecInfo
!= NULL
) {
884 status_t ret
= fWriter
->CreateEncoder(&fEncoder
, codecInfo
, format
);
886 TRACE("BMediaTrack::BMediaTrack: Error: creating decoder failed: "
887 "%s\n", strerror(ret
));
888 // We do not set fInitStatus here, because WriteChunk should still
892 fCodecInfo
= *codecInfo
;
893 fInitStatus
= fEncoder
->SetUp(format
);
908 // Does nothing, returns B_ERROR, for Zeta compatiblity only
910 BMediaTrack::ControlCodec(int32 selector
, void* io_data
, size_t size
)
917 BMediaTrack::SetupWorkaround()
922 get_thread_info(find_thread(0), &tinfo
);
923 be_roster
->GetRunningAppInfo(tinfo
.team
, &ainfo
);
925 if (strcmp(ainfo
.signature
, "application/x-vnd.marcone-soundplay") == 0) {
926 fWorkaroundFlags
= FORCE_RAW_AUDIO
| FORCE_RAW_AUDIO_INT16_FORMAT
927 | FORCE_RAW_AUDIO_HOST_ENDIAN
;
928 printf("BMediaTrack::SetupWorkaround: SoundPlay workaround active\n");
930 if (strcmp(ainfo
.signature
, "application/x-vnd.Be.MediaPlayer") == 0) {
931 fWorkaroundFlags
= IGNORE_ENCODED_AUDIO
| IGNORE_ENCODED_VIDEO
;
932 printf("BMediaTrack::SetupWorkaround: MediaPlayer workaround active\n");
937 if (!(fWorkaroundFlags
& FORCE_RAW_AUDIO_INT16_FORMAT
))
938 fWorkaroundFlags
|= FORCE_RAW_AUDIO_INT32_FORMAT
;
944 BMediaTrack::SetupFormatTranslation(const media_format
&from
, media_format
* to
)
946 gPluginManager
.DestroyDecoder(fRawDecoder
);
949 #ifdef TRACE_MEDIA_TRACK
951 string_for_format(from
, s
, sizeof(s
));
952 printf("BMediaTrack::SetupFormatTranslation: from: %s\n", s
);
955 status_t result
= gPluginManager
.CreateDecoder(&fRawDecoder
, from
);
956 if (result
!= B_OK
) {
957 ERROR("BMediaTrack::SetupFormatTranslation: CreateDecoder failed\n");
962 int buffer_size
= from
.u
.raw_audio
.buffer_size
;
963 int frame_size
= (from
.u
.raw_audio
.format
& 15)
964 * from
.u
.raw_audio
.channel_count
;
965 media_format fromNotConst
= from
;
967 ChunkProvider
* chunkProvider
968 = new (std::nothrow
) RawDecoderChunkProvider(fDecoder
, buffer_size
,
970 if (chunkProvider
== NULL
) {
971 ERROR("BMediaTrack::SetupFormatTranslation: can't create chunk "
975 fRawDecoder
->SetChunkProvider(chunkProvider
);
977 result
= fRawDecoder
->Setup(&fromNotConst
, 0, 0);
978 if (result
!= B_OK
) {
979 ERROR("BMediaTrack::SetupFormatTranslation: Setup failed\n");
983 #ifdef TRACE_MEDIA_TRACK
984 string_for_format(*to
, s
, sizeof(s
));
985 printf("BMediaTrack::SetupFormatTranslation: to: %s\n", s
);
988 result
= fRawDecoder
->NegotiateOutputFormat(to
);
989 if (result
!= B_OK
) {
990 ERROR("BMediaTrack::SetupFormatTranslation: NegotiateOutputFormat "
995 #ifdef TRACE_MEDIA_TRACK
996 string_for_format(*to
, s
, sizeof(s
));
997 printf("BMediaTrack::SetupFormatTranslation: result: %s\n", s
);
1003 gPluginManager
.DestroyDecoder(fRawDecoder
);
1010 BMediaTrack::_FrameRate() const
1012 switch (fFormat
.type
) {
1013 case B_MEDIA_RAW_VIDEO
:
1014 return fFormat
.u
.raw_video
.field_rate
;
1015 case B_MEDIA_ENCODED_VIDEO
:
1016 return fFormat
.u
.encoded_video
.output
.field_rate
;
1017 case B_MEDIA_RAW_AUDIO
:
1018 return fFormat
.u
.raw_audio
.frame_rate
;
1019 case B_MEDIA_ENCODED_AUDIO
:
1020 return fFormat
.u
.encoded_audio
.output
.frame_rate
;
1028 BMediaTrack::BMediaTrack()
1029 BMediaTrack::BMediaTrack(const BMediaTrack
&)
1030 BMediaTrack
&BMediaTrack::operator=(const BMediaTrack
&)
1033 status_t
BMediaTrack::_Reserved_BMediaTrack_0(int32 arg
, ...) { return B_ERROR
; }
1034 status_t
BMediaTrack::_Reserved_BMediaTrack_1(int32 arg
, ...) { return B_ERROR
; }
1035 status_t
BMediaTrack::_Reserved_BMediaTrack_2(int32 arg
, ...) { return B_ERROR
; }
1036 status_t
BMediaTrack::_Reserved_BMediaTrack_3(int32 arg
, ...) { return B_ERROR
; }
1037 status_t
BMediaTrack::_Reserved_BMediaTrack_4(int32 arg
, ...) { return B_ERROR
; }
1038 status_t
BMediaTrack::_Reserved_BMediaTrack_5(int32 arg
, ...) { return B_ERROR
; }
1039 status_t
BMediaTrack::_Reserved_BMediaTrack_6(int32 arg
, ...) { return B_ERROR
; }
1040 status_t
BMediaTrack::_Reserved_BMediaTrack_7(int32 arg
, ...) { return B_ERROR
; }
1041 status_t
BMediaTrack::_Reserved_BMediaTrack_8(int32 arg
, ...) { return B_ERROR
; }
1042 status_t
BMediaTrack::_Reserved_BMediaTrack_9(int32 arg
, ...) { return B_ERROR
; }
1043 status_t
BMediaTrack::_Reserved_BMediaTrack_10(int32 arg
, ...) { return B_ERROR
; }
1044 status_t
BMediaTrack::_Reserved_BMediaTrack_11(int32 arg
, ...) { return B_ERROR
; }
1045 status_t
BMediaTrack::_Reserved_BMediaTrack_12(int32 arg
, ...) { return B_ERROR
; }
1046 status_t
BMediaTrack::_Reserved_BMediaTrack_13(int32 arg
, ...) { return B_ERROR
; }
1047 status_t
BMediaTrack::_Reserved_BMediaTrack_14(int32 arg
, ...) { return B_ERROR
; }
1048 status_t
BMediaTrack::_Reserved_BMediaTrack_15(int32 arg
, ...) { return B_ERROR
; }
1049 status_t
BMediaTrack::_Reserved_BMediaTrack_16(int32 arg
, ...) { return B_ERROR
; }
1050 status_t
BMediaTrack::_Reserved_BMediaTrack_17(int32 arg
, ...) { return B_ERROR
; }
1051 status_t
BMediaTrack::_Reserved_BMediaTrack_18(int32 arg
, ...) { return B_ERROR
; }
1052 status_t
BMediaTrack::_Reserved_BMediaTrack_19(int32 arg
, ...) { return B_ERROR
; }
1053 status_t
BMediaTrack::_Reserved_BMediaTrack_20(int32 arg
, ...) { return B_ERROR
; }
1054 status_t
BMediaTrack::_Reserved_BMediaTrack_21(int32 arg
, ...) { return B_ERROR
; }
1055 status_t
BMediaTrack::_Reserved_BMediaTrack_22(int32 arg
, ...) { return B_ERROR
; }
1056 status_t
BMediaTrack::_Reserved_BMediaTrack_23(int32 arg
, ...) { return B_ERROR
; }
1057 status_t
BMediaTrack::_Reserved_BMediaTrack_24(int32 arg
, ...) { return B_ERROR
; }
1058 status_t
BMediaTrack::_Reserved_BMediaTrack_25(int32 arg
, ...) { return B_ERROR
; }
1059 status_t
BMediaTrack::_Reserved_BMediaTrack_26(int32 arg
, ...) { return B_ERROR
; }
1060 status_t
BMediaTrack::_Reserved_BMediaTrack_27(int32 arg
, ...) { return B_ERROR
; }
1061 status_t
BMediaTrack::_Reserved_BMediaTrack_28(int32 arg
, ...) { return B_ERROR
; }
1062 status_t
BMediaTrack::_Reserved_BMediaTrack_29(int32 arg
, ...) { return B_ERROR
; }
1063 status_t
BMediaTrack::_Reserved_BMediaTrack_30(int32 arg
, ...) { return B_ERROR
; }
1064 status_t
BMediaTrack::_Reserved_BMediaTrack_31(int32 arg
, ...) { return B_ERROR
; }
1065 status_t
BMediaTrack::_Reserved_BMediaTrack_32(int32 arg
, ...) { return B_ERROR
; }
1066 status_t
BMediaTrack::_Reserved_BMediaTrack_33(int32 arg
, ...) { return B_ERROR
; }
1067 status_t
BMediaTrack::_Reserved_BMediaTrack_34(int32 arg
, ...) { return B_ERROR
; }
1068 status_t
BMediaTrack::_Reserved_BMediaTrack_35(int32 arg
, ...) { return B_ERROR
; }
1069 status_t
BMediaTrack::_Reserved_BMediaTrack_36(int32 arg
, ...) { return B_ERROR
; }
1070 status_t
BMediaTrack::_Reserved_BMediaTrack_37(int32 arg
, ...) { return B_ERROR
; }
1071 status_t
BMediaTrack::_Reserved_BMediaTrack_38(int32 arg
, ...) { return B_ERROR
; }
1072 status_t
BMediaTrack::_Reserved_BMediaTrack_39(int32 arg
, ...) { return B_ERROR
; }
1073 status_t
BMediaTrack::_Reserved_BMediaTrack_40(int32 arg
, ...) { return B_ERROR
; }
1074 status_t
BMediaTrack::_Reserved_BMediaTrack_41(int32 arg
, ...) { return B_ERROR
; }
1075 status_t
BMediaTrack::_Reserved_BMediaTrack_42(int32 arg
, ...) { return B_ERROR
; }
1076 status_t
BMediaTrack::_Reserved_BMediaTrack_43(int32 arg
, ...) { return B_ERROR
; }
1077 status_t
BMediaTrack::_Reserved_BMediaTrack_44(int32 arg
, ...) { return B_ERROR
; }
1078 status_t
BMediaTrack::_Reserved_BMediaTrack_45(int32 arg
, ...) { return B_ERROR
; }
1079 status_t
BMediaTrack::_Reserved_BMediaTrack_46(int32 arg
, ...) { return B_ERROR
; }
1080 status_t
BMediaTrack::_Reserved_BMediaTrack_47(int32 arg
, ...) { return B_ERROR
; }
1083 RawDecoderChunkProvider::RawDecoderChunkProvider(Decoder
* decoder
,
1084 int buffer_size
, int frame_size
)
1086 // printf("RawDecoderChunkProvider: buffer_size %d, frame_size %d\n",
1087 // buffer_size, frame_size);
1089 fFrameSize
= frame_size
;
1090 fBufferSize
= buffer_size
;
1091 fBuffer
= malloc(buffer_size
);
1095 RawDecoderChunkProvider::~RawDecoderChunkProvider()
1102 RawDecoderChunkProvider::GetNextChunk(const void** chunkBuffer
,
1103 size_t* chunkSize
, media_header
* header
)
1106 media_decode_info info
;
1107 status_t result
= fDecoder
->Decode(fBuffer
, &frames
, header
, &info
);
1108 if (result
== B_OK
) {
1109 *chunkBuffer
= fBuffer
;
1110 *chunkSize
= frames
* fFrameSize
;
1111 // printf("RawDecoderChunkProvider::GetNextChunk, %lld frames, "
1112 // "%ld bytes, start-time %lld\n", frames, *chunkSize,
1113 // header->start_time);
1115 ERROR("RawDecoderChunkProvider::GetNextChunk failed\n");