* Writer::WriteChunk() takes media_encode_info* instead of flags.
* Improved Encoder API towards what we need for the get_next_encoder() variants and the BMediaTrack API. * Implemented the rest of MediaWriter. Still undecided what to make of AddTrackInfo(). BMediaEncoder has that as well, which hints that this is something the Encoder needs to support. But it could also be that this is only possible to support in Writer. * Wired a lot of previously unimplemented methods in BMediaFile and BMediaTrack needed for write support. If I have not overlooked anything, only the parameter stuff is still unimplemented now. This is all untested, since the FFMpeg Encoder and Writer are still only stubs. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@32013 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -1,10 +1,11 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2002-2009, Haiku, Inc. All rights reserved.
|
* Copyright 2002-2009, Haiku, Inc. All rights reserved.
|
||||||
* Distributed under the terms of the MIT License.
|
* Distributed under the terms of the MIT license.
|
||||||
*/
|
*/
|
||||||
#ifndef _MEDIA_FILE_H
|
#ifndef _MEDIA_FILE_H
|
||||||
#define _MEDIA_FILE_H
|
#define _MEDIA_FILE_H
|
||||||
|
|
||||||
|
|
||||||
#include <image.h>
|
#include <image.h>
|
||||||
#include <List.h>
|
#include <List.h>
|
||||||
#include <MediaDefs.h>
|
#include <MediaDefs.h>
|
||||||
@@ -15,8 +16,8 @@
|
|||||||
namespace BPrivate {
|
namespace BPrivate {
|
||||||
namespace media {
|
namespace media {
|
||||||
class MediaExtractor;
|
class MediaExtractor;
|
||||||
|
class MediaWriter;
|
||||||
}
|
}
|
||||||
class MediaWriter;
|
|
||||||
class _AddonManager;
|
class _AddonManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -147,7 +148,7 @@ private:
|
|||||||
|
|
||||||
BPrivate::_AddonManager* fEncoderMgr;
|
BPrivate::_AddonManager* fEncoderMgr;
|
||||||
BPrivate::_AddonManager* fWriterMgr;
|
BPrivate::_AddonManager* fWriterMgr;
|
||||||
BPrivate::MediaWriter* fWriter;
|
BPrivate::media::MediaWriter* fWriter;
|
||||||
int32 fWriterID;
|
int32 fWriterID;
|
||||||
media_file_format fMFI;
|
media_file_format fMFI;
|
||||||
|
|
||||||
@@ -159,8 +160,9 @@ private:
|
|||||||
void _Init();
|
void _Init();
|
||||||
void _UnInit();
|
void _UnInit();
|
||||||
void _InitReader(BDataIO* source, int32 flags = 0);
|
void _InitReader(BDataIO* source, int32 flags = 0);
|
||||||
void _InitWriter(BDataIO* source,
|
void _InitWriter(BDataIO* target,
|
||||||
const media_file_format* mfi, int32 flags);
|
const media_file_format* fileFormat,
|
||||||
|
int32 flags);
|
||||||
|
|
||||||
BMediaFile();
|
BMediaFile();
|
||||||
BMediaFile(const BMediaFile&);
|
BMediaFile(const BMediaFile&);
|
||||||
|
|||||||
@@ -217,9 +217,9 @@ private:
|
|||||||
|
|
||||||
// For write-only access to a BMediaTrack
|
// For write-only access to a BMediaTrack
|
||||||
BMediaTrack(BPrivate::media::MediaWriter* writer,
|
BMediaTrack(BPrivate::media::MediaWriter* writer,
|
||||||
int32 streamIndex, media_format* format,
|
int32 streamIndex,
|
||||||
BPrivate::media::Encoder* encoder,
|
const media_format* format,
|
||||||
media_codec_info* codecInfo);
|
const media_codec_info* codecInfo);
|
||||||
|
|
||||||
void SetupWorkaround();
|
void SetupWorkaround();
|
||||||
bool SetupFormatTranslation(const media_format& from,
|
bool SetupFormatTranslation(const media_format& from,
|
||||||
|
|||||||
@@ -21,7 +21,8 @@ class ChunkWriter {
|
|||||||
public:
|
public:
|
||||||
virtual ~ChunkWriter() {};
|
virtual ~ChunkWriter() {};
|
||||||
virtual status_t WriteChunk(const void* chunkBuffer,
|
virtual status_t WriteChunk(const void* chunkBuffer,
|
||||||
size_t chunkSize, uint32 flags) = 0;
|
size_t chunkSize,
|
||||||
|
media_encode_info* encodeInfo) = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@@ -30,29 +31,42 @@ public:
|
|||||||
Encoder();
|
Encoder();
|
||||||
virtual ~Encoder();
|
virtual ~Encoder();
|
||||||
|
|
||||||
// TODO: I think we may actually need a method to specialize a
|
// Some codecs may only support certain input color spaces, or output
|
||||||
// media_format. For example, some codecs may only support certain
|
// color spaces, or multiple of 16 width/height... This method is needed
|
||||||
// input color spaces, or output color spaces, or multiple of 16
|
// for get_next_encoder() functionality. If _acceptedInputFormat is NULL,
|
||||||
// width/height... This support is technically even needed for
|
// you simply return a status indicating if proposed format is acceptable.
|
||||||
// MediaFormats.h functionality, although there probably isn't
|
// If it contains wildcards for fields that you have restrictions on,
|
||||||
// an application out there which uses it like that.
|
// return an error. In that case, the user should be using the form of
|
||||||
|
// get_next_encoder() that allows to specify the accepted format. If
|
||||||
|
// _acceptedInputFormat is not NULL, copy the proposedFormat into
|
||||||
|
// _acceptedInputFormat and specialize any wildcards. You must (!) also
|
||||||
|
// change non-wildcard fields, like the video width if you want to round to
|
||||||
|
// the nearest multiple of 16 for example. Only if the format is completely
|
||||||
|
// unacceptable, return an error.
|
||||||
|
virtual status_t AcceptedFormat(
|
||||||
|
const media_format* proposedInputFormat,
|
||||||
|
media_format* _acceptedInputFormat = NULL)
|
||||||
|
= 0;
|
||||||
|
|
||||||
virtual status_t SetFormat(const media_file_format& fileFormat,
|
// The passed media_format may not contain wildcards and must be the same
|
||||||
media_format* _inOutEncodedFormat) = 0;
|
// format that was passed to get_next_encoder() (or it must be the format
|
||||||
|
// returned in _acceptedInputFormat).
|
||||||
|
virtual status_t SetUp(const media_format* inputFormat) = 0;
|
||||||
|
|
||||||
virtual status_t AddTrackInfo(uint32 code, const void* data,
|
virtual status_t AddTrackInfo(uint32 code, const void* data,
|
||||||
size_t size, uint32 flags = 0) = 0;
|
size_t size, uint32 flags = 0);
|
||||||
|
|
||||||
virtual status_t GetEncodeParameters(
|
virtual status_t GetEncodeParameters(
|
||||||
encode_parameters* parameters) const = 0;
|
encode_parameters* parameters) const;
|
||||||
virtual status_t SetEncodeParameters(
|
virtual status_t SetEncodeParameters(
|
||||||
encode_parameters* parameters) const = 0;
|
encode_parameters* parameters) const;
|
||||||
|
|
||||||
virtual status_t Encode(const void* buffer, int64 frameCount,
|
virtual status_t Encode(const void* buffer, int64 frameCount,
|
||||||
media_encode_info* info) = 0;
|
media_encode_info* info) = 0;
|
||||||
|
|
||||||
status_t WriteChunk(const void* chunkBuffer,
|
status_t WriteChunk(const void* chunkBuffer,
|
||||||
size_t chunkSize, uint32 flags = 0);
|
size_t chunkSize,
|
||||||
|
media_encode_info* encodeInfo);
|
||||||
|
|
||||||
void SetChunkWriter(ChunkWriter* writer);
|
void SetChunkWriter(ChunkWriter* writer);
|
||||||
|
|
||||||
|
|||||||
@@ -25,22 +25,24 @@ public:
|
|||||||
|
|
||||||
void GetFileFormatInfo(media_file_format* mfi) const;
|
void GetFileFormatInfo(media_file_format* mfi) const;
|
||||||
|
|
||||||
|
status_t CreateEncoder(Encoder** _encoder,
|
||||||
|
const media_codec_info* codecInfo,
|
||||||
|
uint32 flags = 0);
|
||||||
|
|
||||||
|
status_t SetCopyright(int32 streamIndex,
|
||||||
|
const char* copyright);
|
||||||
status_t SetCopyright(const char* copyright);
|
status_t SetCopyright(const char* copyright);
|
||||||
status_t CommitHeader();
|
status_t CommitHeader();
|
||||||
status_t Flush();
|
status_t Flush();
|
||||||
status_t Close();
|
status_t Close();
|
||||||
|
|
||||||
status_t AddTrackInfo(void* cookie, uint32 code,
|
status_t AddTrackInfo(int32 streamIndex, uint32 code,
|
||||||
const void* data, size_t size,
|
const void* data, size_t size,
|
||||||
uint32 flags = 0);
|
uint32 flags = 0);
|
||||||
|
|
||||||
status_t CreateEncoder(Encoder** _encoder,
|
status_t WriteChunk(int32 streamIndex,
|
||||||
const media_codec_info* codecInfo,
|
|
||||||
uint32 flags = 0);
|
|
||||||
|
|
||||||
status_t WriteChunk(int32 stream,
|
|
||||||
const void* chunkBuffer, size_t chunkSize,
|
const void* chunkBuffer, size_t chunkSize,
|
||||||
uint32 flags);
|
media_encode_info* encodeInfo);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
struct StreamInfo {
|
struct StreamInfo {
|
||||||
|
|||||||
@@ -21,13 +21,16 @@ public:
|
|||||||
virtual status_t AllocateCookie(void** cookie) = 0;
|
virtual status_t AllocateCookie(void** cookie) = 0;
|
||||||
virtual status_t FreeCookie(void* cookie) = 0;
|
virtual status_t FreeCookie(void* cookie) = 0;
|
||||||
|
|
||||||
|
virtual status_t SetCopyright(void* cookie,
|
||||||
|
const char* copyright) = 0;
|
||||||
|
|
||||||
virtual status_t AddTrackInfo(void* cookie, uint32 code,
|
virtual status_t AddTrackInfo(void* cookie, uint32 code,
|
||||||
const void* data, size_t size,
|
const void* data, size_t size,
|
||||||
uint32 flags = 0) = 0;
|
uint32 flags = 0) = 0;
|
||||||
|
|
||||||
virtual status_t WriteChunk(void* cookie,
|
virtual status_t WriteChunk(void* cookie,
|
||||||
const void* chunkBuffer, size_t chunkSize,
|
const void* chunkBuffer, size_t chunkSize,
|
||||||
uint32 flags) = 0;
|
media_encode_info* encodeInfo) = 0;
|
||||||
|
|
||||||
BDataIO* Target() const;
|
BDataIO* Target() const;
|
||||||
|
|
||||||
|
|||||||
@@ -33,21 +33,31 @@ AVCodecEncoder::~AVCodecEncoder()
|
|||||||
|
|
||||||
|
|
||||||
status_t
|
status_t
|
||||||
AVCodecEncoder::SetFormat(const media_file_format& fileFormat,
|
AVCodecEncoder::AcceptedFormat(const media_format* proposedInputFormat,
|
||||||
media_format* _inOutEncodedFormat)
|
media_format* _acceptedInputFormat)
|
||||||
{
|
{
|
||||||
TRACE("AVCodecEncoder::SetFormat()\n");
|
TRACE("AVCodecEncoder::AcceptedFormat(%p, %p)\n", proposedInputFormat,
|
||||||
|
_acceptedInputFormat);
|
||||||
|
|
||||||
return B_NOT_SUPPORTED;
|
if (proposedInputFormat == NULL)
|
||||||
|
return B_BAD_VALUE;
|
||||||
|
|
||||||
|
if (_acceptedInputFormat != NULL) {
|
||||||
|
memcpy(_acceptedInputFormat, proposedInputFormat,
|
||||||
|
sizeof(media_format));
|
||||||
|
}
|
||||||
|
|
||||||
|
return B_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
status_t
|
status_t
|
||||||
AVCodecEncoder::AddTrackInfo(uint32 code, const void* data, size_t size,
|
AVCodecEncoder::SetUp(const media_format* inputFormat)
|
||||||
uint32 flags)
|
|
||||||
{
|
{
|
||||||
TRACE("AVCodecEncoder::AddTrackInfo(%lu, %p, %ld, %lu)\n", code, data,
|
TRACE("AVCodecEncoder::SetUp()\n");
|
||||||
size, flags);
|
|
||||||
|
if (inputFormat == NULL)
|
||||||
|
return B_BAD_VALUE;
|
||||||
|
|
||||||
return B_NOT_SUPPORTED;
|
return B_NOT_SUPPORTED;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,11 +17,11 @@ public:
|
|||||||
|
|
||||||
virtual ~AVCodecEncoder();
|
virtual ~AVCodecEncoder();
|
||||||
|
|
||||||
virtual status_t SetFormat(const media_file_format& fileFormat,
|
virtual status_t AcceptedFormat(
|
||||||
media_format* _inOutEncodedFormat);
|
const media_format* proposedInputFormat,
|
||||||
|
media_format* _acceptedInputFormat = NULL);
|
||||||
|
|
||||||
virtual status_t AddTrackInfo(uint32 code, const void* data,
|
virtual status_t SetUp(const media_format* inputFormat);
|
||||||
size_t size, uint32 flags = 0);
|
|
||||||
|
|
||||||
virtual status_t GetEncodeParameters(
|
virtual status_t GetEncodeParameters(
|
||||||
encode_parameters* parameters) const;
|
encode_parameters* parameters) const;
|
||||||
|
|||||||
@@ -172,6 +172,15 @@ AVFormatWriter::FreeCookie(void* _cookie)
|
|||||||
// #pragma mark -
|
// #pragma mark -
|
||||||
|
|
||||||
|
|
||||||
|
status_t
|
||||||
|
AVFormatWriter::SetCopyright(void* cookie, const char* copyright)
|
||||||
|
{
|
||||||
|
TRACE("AVFormatWriter::SetCopyright(%p, %s)\n", cookie, copyright);
|
||||||
|
|
||||||
|
return B_NOT_SUPPORTED;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
status_t
|
status_t
|
||||||
AVFormatWriter::AddTrackInfo(void* cookie, uint32 code,
|
AVFormatWriter::AddTrackInfo(void* cookie, uint32 code,
|
||||||
const void* data, size_t size, uint32 flags)
|
const void* data, size_t size, uint32 flags)
|
||||||
@@ -185,10 +194,10 @@ AVFormatWriter::AddTrackInfo(void* cookie, uint32 code,
|
|||||||
|
|
||||||
status_t
|
status_t
|
||||||
AVFormatWriter::WriteChunk(void* cookie, const void* chunkBuffer,
|
AVFormatWriter::WriteChunk(void* cookie, const void* chunkBuffer,
|
||||||
size_t chunkSize, uint32 flags)
|
size_t chunkSize, media_encode_info* encodeInfo)
|
||||||
{
|
{
|
||||||
TRACE("AVFormatWriter::WriteChunk(%p, %ld, %lu)\n", chunkBuffer, chunkSize,
|
TRACE("AVFormatWriter::WriteChunk(%p, %ld, %p)\n", chunkBuffer, chunkSize,
|
||||||
flags);
|
encodeInfo);
|
||||||
|
|
||||||
return B_NOT_SUPPORTED;
|
return B_NOT_SUPPORTED;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -24,13 +24,16 @@ public:
|
|||||||
virtual status_t AllocateCookie(void** cookie);
|
virtual status_t AllocateCookie(void** cookie);
|
||||||
virtual status_t FreeCookie(void* cookie);
|
virtual status_t FreeCookie(void* cookie);
|
||||||
|
|
||||||
|
virtual status_t SetCopyright(void* cookie,
|
||||||
|
const char* copyright);
|
||||||
|
|
||||||
virtual status_t AddTrackInfo(void* cookie, uint32 code,
|
virtual status_t AddTrackInfo(void* cookie, uint32 code,
|
||||||
const void* data, size_t size,
|
const void* data, size_t size,
|
||||||
uint32 flags = 0);
|
uint32 flags = 0);
|
||||||
|
|
||||||
virtual status_t WriteChunk(void* cookie,
|
virtual status_t WriteChunk(void* cookie,
|
||||||
const void* chunkBuffer, size_t chunkSize,
|
const void* chunkBuffer, size_t chunkSize,
|
||||||
uint32 flags);
|
media_encode_info* encodeInfo);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
class StreamCookie;
|
class StreamCookie;
|
||||||
|
|||||||
@@ -27,9 +27,31 @@ Encoder::~Encoder()
|
|||||||
|
|
||||||
|
|
||||||
status_t
|
status_t
|
||||||
Encoder::WriteChunk(const void* chunkBuffer, size_t chunkSize, uint32 flags)
|
Encoder::AddTrackInfo(uint32 code, const void* data, size_t size, uint32 flags)
|
||||||
{
|
{
|
||||||
return fChunkWriter->WriteChunk(chunkBuffer, chunkSize, flags);
|
return B_NOT_SUPPORTED;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
status_t
|
||||||
|
Encoder::GetEncodeParameters(encode_parameters* parameters) const
|
||||||
|
{
|
||||||
|
return B_NOT_SUPPORTED;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
status_t
|
||||||
|
Encoder::SetEncodeParameters(encode_parameters* parameters) const
|
||||||
|
{
|
||||||
|
return B_NOT_SUPPORTED;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
status_t
|
||||||
|
Encoder::WriteChunk(const void* chunkBuffer, size_t chunkSize,
|
||||||
|
media_encode_info* encodeInfo)
|
||||||
|
{
|
||||||
|
return fChunkWriter->WriteChunk(chunkBuffer, chunkSize, encodeInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,18 +1,23 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2002-2004, Marcus Overhagen <marcus@overhagen.de>
|
* Copyright 2009, Stephan Aßmus <superstippi@gmx.de>
|
||||||
* All rights reserved. Distributed under the terms of the MIT License.
|
* Copyright 2002-2004, Marcus Overhagen <marcus@overhagen.de>
|
||||||
|
* All rights reserved. Distributed under the terms of the MIT license.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <MediaFile.h>
|
#include <MediaFile.h>
|
||||||
|
|
||||||
#include <new>
|
#include <new>
|
||||||
|
|
||||||
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
#include <MediaTrack.h>
|
|
||||||
#include <File.h>
|
#include <File.h>
|
||||||
|
#include <MediaTrack.h>
|
||||||
|
|
||||||
|
#include "debug.h"
|
||||||
|
|
||||||
#include "MediaExtractor.h"
|
#include "MediaExtractor.h"
|
||||||
#include "debug.h"
|
#include "MediaWriter.h"
|
||||||
|
|
||||||
|
|
||||||
BMediaFile::BMediaFile(const entry_ref* ref)
|
BMediaFile::BMediaFile(const entry_ref* ref)
|
||||||
@@ -20,7 +25,7 @@ BMediaFile::BMediaFile(const entry_ref* ref)
|
|||||||
CALLED();
|
CALLED();
|
||||||
_Init();
|
_Init();
|
||||||
fDeleteSource = true;
|
fDeleteSource = true;
|
||||||
_InitReader(new (std::nothrow) BFile(ref, O_RDONLY));
|
_InitReader(new(std::nothrow) BFile(ref, O_RDONLY));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -37,7 +42,7 @@ BMediaFile::BMediaFile(const entry_ref* ref, int32 flags)
|
|||||||
CALLED();
|
CALLED();
|
||||||
_Init();
|
_Init();
|
||||||
fDeleteSource = true;
|
fDeleteSource = true;
|
||||||
_InitReader(new (std::nothrow) BFile(ref, O_RDONLY), flags);
|
_InitReader(new(std::nothrow) BFile(ref, O_RDONLY), flags);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -55,7 +60,7 @@ BMediaFile::BMediaFile(const entry_ref* ref, const media_file_format* mfi,
|
|||||||
CALLED();
|
CALLED();
|
||||||
_Init();
|
_Init();
|
||||||
fDeleteSource = true;
|
fDeleteSource = true;
|
||||||
_InitWriter(new (std::nothrow) BFile(ref, O_WRONLY), mfi, flags);
|
_InitWriter(new(std::nothrow) BFile(ref, O_WRONLY), mfi, flags);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -85,7 +90,7 @@ BMediaFile::SetTo(const entry_ref* ref)
|
|||||||
|
|
||||||
_UnInit();
|
_UnInit();
|
||||||
fDeleteSource = true;
|
fDeleteSource = true;
|
||||||
_InitReader(new (std::nothrow) BFile(ref, O_RDONLY));
|
_InitReader(new(std::nothrow) BFile(ref, O_RDONLY));
|
||||||
|
|
||||||
return fErr;
|
return fErr;
|
||||||
}
|
}
|
||||||
@@ -162,7 +167,7 @@ BMediaFile::TrackAt(int32 index)
|
|||||||
}
|
}
|
||||||
if (fTrackList[index] == NULL) {
|
if (fTrackList[index] == NULL) {
|
||||||
TRACE("BMediaFile::TrackAt, creating new track for index %ld\n", index);
|
TRACE("BMediaFile::TrackAt, creating new track for index %ld\n", index);
|
||||||
fTrackList[index] = new (std::nothrow) BMediaTrack(fExtractor, index);
|
fTrackList[index] = new(std::nothrow) BMediaTrack(fExtractor, index);
|
||||||
TRACE("BMediaFile::TrackAt, new track is %p\n", fTrackList[index]);
|
TRACE("BMediaFile::TrackAt, new track is %p\n", fTrackList[index]);
|
||||||
}
|
}
|
||||||
return fTrackList[index];
|
return fTrackList[index];
|
||||||
@@ -213,11 +218,32 @@ BMediaFile::ReleaseAllTracks()
|
|||||||
|
|
||||||
// Create and add a track to the media file
|
// Create and add a track to the media file
|
||||||
BMediaTrack*
|
BMediaTrack*
|
||||||
BMediaFile::CreateTrack(media_format* mf, const media_codec_info* mci,
|
BMediaFile::CreateTrack(media_format* mediaFormat,
|
||||||
uint32 flags)
|
const media_codec_info* codecInfo, uint32 flags)
|
||||||
{
|
{
|
||||||
UNIMPLEMENTED();
|
if (mediaFormat == NULL)
|
||||||
return 0;
|
return NULL;
|
||||||
|
|
||||||
|
// NOTE: It is allowed to pass NULL for codecInfo. In that case, the
|
||||||
|
// track won't have an Encoder and you can only use WriteChunk() with
|
||||||
|
// already encoded data.
|
||||||
|
|
||||||
|
// Make room for the new track.
|
||||||
|
BMediaTrack** trackList = (BMediaTrack**)realloc(fTrackList,
|
||||||
|
(fTrackNum + 1) * sizeof(BMediaTrack*));
|
||||||
|
if (trackList == NULL)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
int32 streamIndex = fTrackNum;
|
||||||
|
fTrackList = trackList;
|
||||||
|
fTrackNum += 1;
|
||||||
|
|
||||||
|
BMediaTrack* track = new(std::nothrow) BMediaTrack(fWriter, streamIndex,
|
||||||
|
mediaFormat, codecInfo);
|
||||||
|
|
||||||
|
fTrackList[streamIndex] = track;
|
||||||
|
|
||||||
|
return track;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -253,10 +279,12 @@ CreateTrack__10BMediaFileP12media_format(BMediaFile* self, media_format* mf)
|
|||||||
|
|
||||||
// Lets you set the copyright info for the entire file
|
// Lets you set the copyright info for the entire file
|
||||||
status_t
|
status_t
|
||||||
BMediaFile::AddCopyright(const char* data)
|
BMediaFile::AddCopyright(const char* copyright)
|
||||||
{
|
{
|
||||||
UNIMPLEMENTED();
|
if (fWriter == NULL)
|
||||||
return B_OK;
|
return B_NO_INIT;
|
||||||
|
|
||||||
|
return fWriter->SetCopyright(copyright);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -273,8 +301,10 @@ BMediaFile::AddChunk(int32 type, const void* data, size_t size)
|
|||||||
status_t
|
status_t
|
||||||
BMediaFile::CommitHeader()
|
BMediaFile::CommitHeader()
|
||||||
{
|
{
|
||||||
UNIMPLEMENTED();
|
if (fWriter == NULL)
|
||||||
return B_OK;
|
return B_NO_INIT;
|
||||||
|
|
||||||
|
return fWriter->CommitHeader();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -282,8 +312,10 @@ BMediaFile::CommitHeader()
|
|||||||
status_t
|
status_t
|
||||||
BMediaFile::CloseFile()
|
BMediaFile::CloseFile()
|
||||||
{
|
{
|
||||||
UNIMPLEMENTED();
|
if (fWriter == NULL)
|
||||||
return B_OK;
|
return B_NO_INIT;
|
||||||
|
|
||||||
|
return fWriter->Close();
|
||||||
}
|
}
|
||||||
|
|
||||||
// This is for controlling file format parameters
|
// This is for controlling file format parameters
|
||||||
@@ -374,7 +406,7 @@ void
|
|||||||
BMediaFile::_UnInit()
|
BMediaFile::_UnInit()
|
||||||
{
|
{
|
||||||
ReleaseAllTracks();
|
ReleaseAllTracks();
|
||||||
delete[] fTrackList;
|
free(fTrackList);
|
||||||
fTrackList = NULL;
|
fTrackList = NULL;
|
||||||
fTrackNum = 0;
|
fTrackNum = 0;
|
||||||
delete fExtractor;
|
delete fExtractor;
|
||||||
@@ -399,7 +431,7 @@ BMediaFile::_InitReader(BDataIO* source, int32 flags)
|
|||||||
|
|
||||||
fSource = source;
|
fSource = source;
|
||||||
|
|
||||||
fExtractor = new (std::nothrow) MediaExtractor(source, flags);
|
fExtractor = new(std::nothrow) MediaExtractor(source, flags);
|
||||||
if (fExtractor == NULL)
|
if (fExtractor == NULL)
|
||||||
fErr = B_NO_MEMORY;
|
fErr = B_NO_MEMORY;
|
||||||
else
|
else
|
||||||
@@ -409,7 +441,7 @@ BMediaFile::_InitReader(BDataIO* source, int32 flags)
|
|||||||
|
|
||||||
fExtractor->GetFileFormatInfo(&fMFI);
|
fExtractor->GetFileFormatInfo(&fMFI);
|
||||||
fTrackNum = fExtractor->StreamCount();
|
fTrackNum = fExtractor->StreamCount();
|
||||||
fTrackList = new (std::nothrow) BMediaTrack*[fTrackNum];
|
fTrackList = (BMediaTrack**)malloc(fTrackNum * sizeof(BMediaTrack*));
|
||||||
if (fTrackList == NULL) {
|
if (fTrackList == NULL) {
|
||||||
fErr = B_NO_MEMORY;
|
fErr = B_NO_MEMORY;
|
||||||
return;
|
return;
|
||||||
@@ -419,12 +451,33 @@ BMediaFile::_InitReader(BDataIO* source, int32 flags)
|
|||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
BMediaFile::_InitWriter(BDataIO* source, const media_file_format* mfi,
|
BMediaFile::_InitWriter(BDataIO* target, const media_file_format* fileFormat,
|
||||||
int32 flags)
|
int32 flags)
|
||||||
{
|
{
|
||||||
UNIMPLEMENTED();
|
CALLED();
|
||||||
fSource = source;
|
|
||||||
fErr = B_NOT_ALLOWED;
|
if (fileFormat == NULL) {
|
||||||
|
fErr = B_BAD_VALUE;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (target == NULL) {
|
||||||
|
fErr = B_NO_MEMORY;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
fMFI = *fileFormat;
|
||||||
|
fSource = target;
|
||||||
|
|
||||||
|
fWriter = new(std::nothrow) MediaWriter(fSource, fMFI);
|
||||||
|
if (fWriter == NULL)
|
||||||
|
fErr = B_NO_MEMORY;
|
||||||
|
else
|
||||||
|
fErr = fWriter->InitCheck();
|
||||||
|
if (fErr != B_OK)
|
||||||
|
return;
|
||||||
|
|
||||||
|
fTrackNum = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,37 +1,26 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2002-2007, Marcus Overhagen <marcus@overhagen.de>
|
* Copyright 2009, Stephan Aßmus <superstippi@gmx.de>
|
||||||
* All rights reserved.
|
* Copyright 2002-2007, Marcus Overhagen <marcus@overhagen.de>
|
||||||
*
|
* All rights reserved. Distributed under the terms of the MIT license.
|
||||||
* Redistribution and use in source and binary forms, with or without modification,
|
|
||||||
* are permitted provided that the following conditions are met:
|
|
||||||
*
|
|
||||||
* * Redistributions of source code must retain the above copyright notice,
|
|
||||||
* this list of conditions and the following disclaimer.
|
|
||||||
* * Redistributions in binary form must reproduce the above copyright notice,
|
|
||||||
* this list of conditions and the following disclaimer in the documentation
|
|
||||||
* 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
|
|
||||||
* 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
|
|
||||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
|
||||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|
||||||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
||||||
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
||||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
#include <MediaTrack.h>
|
#include <MediaTrack.h>
|
||||||
#include <Roster.h>
|
|
||||||
|
#include <new>
|
||||||
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <new>
|
|
||||||
#include "MediaExtractor.h"
|
#include <Roster.h>
|
||||||
#include "PluginManager.h"
|
|
||||||
#include "debug.h"
|
#include "debug.h"
|
||||||
|
|
||||||
|
#include "MediaExtractor.h"
|
||||||
|
#include "MediaWriter.h"
|
||||||
|
#include "PluginManager.h"
|
||||||
|
|
||||||
|
|
||||||
//#define TRACE_MEDIA_TRACK
|
//#define TRACE_MEDIA_TRACK
|
||||||
#ifdef TRACE_MEDIA_TRACK
|
#ifdef TRACE_MEDIA_TRACK
|
||||||
#ifndef TRACE
|
#ifndef TRACE
|
||||||
@@ -525,81 +514,79 @@ BMediaTrack::ReadChunk(char **out_buffer,
|
|||||||
|
|
||||||
|
|
||||||
status_t
|
status_t
|
||||||
BMediaTrack::AddCopyright(const char *data)
|
BMediaTrack::AddCopyright(const char* copyright)
|
||||||
{
|
{
|
||||||
UNIMPLEMENTED();
|
if (fWriter == NULL)
|
||||||
|
return B_NO_INIT;
|
||||||
|
|
||||||
return B_OK;
|
return fWriter->SetCopyright(fStream, copyright);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
status_t
|
status_t
|
||||||
BMediaTrack::AddTrackInfo(uint32 code,
|
BMediaTrack::AddTrackInfo(uint32 code, const void* data, size_t size,
|
||||||
const void *data,
|
uint32 flags)
|
||||||
size_t size,
|
|
||||||
uint32 flags)
|
|
||||||
{
|
{
|
||||||
UNIMPLEMENTED();
|
if (fWriter == NULL)
|
||||||
|
return B_NO_INIT;
|
||||||
|
|
||||||
return B_OK;
|
return fWriter->AddTrackInfo(fStream, code, data, size, flags);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
status_t
|
status_t
|
||||||
BMediaTrack::WriteFrames(const void *data,
|
BMediaTrack::WriteFrames(const void* data, int32 frameCount, int32 flags)
|
||||||
int32 num_frames,
|
|
||||||
int32 flags)
|
|
||||||
{
|
{
|
||||||
UNIMPLEMENTED();
|
media_encode_info encodeInfo;
|
||||||
|
encodeInfo.flags = flags;
|
||||||
|
|
||||||
return B_OK;
|
return WriteFrames(data, frameCount, &encodeInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
status_t
|
status_t
|
||||||
BMediaTrack::WriteFrames(const void *data,
|
BMediaTrack::WriteFrames(const void* data, int64 frameCount,
|
||||||
int64 num_frames,
|
media_encode_info* info)
|
||||||
media_encode_info *info)
|
|
||||||
{
|
{
|
||||||
UNIMPLEMENTED();
|
if (fEncoder == NULL)
|
||||||
|
return B_NO_INIT;
|
||||||
|
|
||||||
return B_OK;
|
return fEncoder->Encode(data, frameCount, info);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
status_t
|
status_t
|
||||||
BMediaTrack::WriteChunk(const void *data,
|
BMediaTrack::WriteChunk(const void* data, size_t size, uint32 flags)
|
||||||
size_t size,
|
|
||||||
uint32 flags)
|
|
||||||
{
|
{
|
||||||
UNIMPLEMENTED();
|
media_encode_info encodeInfo;
|
||||||
|
encodeInfo.flags = flags;
|
||||||
|
|
||||||
return B_OK;
|
return WriteChunk(data, size, &encodeInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
status_t
|
status_t
|
||||||
BMediaTrack::WriteChunk(const void *data,
|
BMediaTrack::WriteChunk(const void* data, size_t size, media_encode_info* info)
|
||||||
size_t size,
|
|
||||||
media_encode_info *info)
|
|
||||||
{
|
{
|
||||||
UNIMPLEMENTED();
|
if (fWriter == NULL)
|
||||||
|
return B_NO_INIT;
|
||||||
|
|
||||||
return B_OK;
|
return fWriter->WriteChunk(fStream, data, size, info);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
status_t
|
status_t
|
||||||
BMediaTrack::Flush()
|
BMediaTrack::Flush()
|
||||||
{
|
{
|
||||||
UNIMPLEMENTED();
|
if (fWriter == NULL)
|
||||||
|
return B_NO_INIT;
|
||||||
|
|
||||||
return B_OK;
|
return fWriter->Flush();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// deprecated BeOS R5 API
|
// deprecated BeOS R5 API
|
||||||
BParameterWeb *
|
BParameterWeb*
|
||||||
BMediaTrack::Web()
|
BMediaTrack::Web()
|
||||||
{
|
{
|
||||||
UNIMPLEMENTED();
|
UNIMPLEMENTED();
|
||||||
@@ -713,9 +700,8 @@ BMediaTrack::BMediaTrack(BPrivate::media::MediaExtractor *extractor,
|
|||||||
if (ret != B_OK) {
|
if (ret != B_OK) {
|
||||||
TRACE("BMediaTrack::BMediaTrack: Error: creating decoder failed: "
|
TRACE("BMediaTrack::BMediaTrack: Error: creating decoder failed: "
|
||||||
"%s\n", strerror(ret));
|
"%s\n", strerror(ret));
|
||||||
// we do not set fErr here, because ReadChunk should still work
|
// We do not set fErr here, because ReadChunk should still work.
|
||||||
fDecoder = NULL;
|
fDecoder = NULL;
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fCurFrame = 0;
|
fCurFrame = 0;
|
||||||
@@ -729,12 +715,41 @@ BMediaTrack::BMediaTrack(BPrivate::media::MediaExtractor *extractor,
|
|||||||
|
|
||||||
|
|
||||||
BMediaTrack::BMediaTrack(BPrivate::media::MediaWriter* writer,
|
BMediaTrack::BMediaTrack(BPrivate::media::MediaWriter* writer,
|
||||||
int32 stream_num,
|
int32 streamIndex, const media_format* format,
|
||||||
media_format *in_format,
|
const media_codec_info* codecInfo)
|
||||||
BPrivate::media::Encoder *encoder,
|
|
||||||
media_codec_info *mci)
|
|
||||||
{
|
{
|
||||||
UNIMPLEMENTED();
|
CALLED();
|
||||||
|
|
||||||
|
fWorkaroundFlags = 0;
|
||||||
|
fEncoder = NULL;
|
||||||
|
fEncoderID = -1;
|
||||||
|
// TODO: Not yet sure what this was needed for...
|
||||||
|
fWriter = writer;
|
||||||
|
fWriterFormat = *format;
|
||||||
|
fStream = streamIndex;
|
||||||
|
fErr = B_OK;
|
||||||
|
|
||||||
|
SetupWorkaround();
|
||||||
|
|
||||||
|
if (codecInfo != NULL) {
|
||||||
|
status_t ret = fWriter->CreateEncoder(&fEncoder, codecInfo);
|
||||||
|
if (ret != B_OK) {
|
||||||
|
TRACE("BMediaTrack::BMediaTrack: Error: creating decoder failed: "
|
||||||
|
"%s\n", strerror(ret));
|
||||||
|
// We do not set fErr here, because WriteChunk should still work.
|
||||||
|
fEncoder = NULL;
|
||||||
|
} else {
|
||||||
|
fMCI = *codecInfo;
|
||||||
|
fErr = fEncoder->SetUp(&fWriterFormat);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// not used:
|
||||||
|
fCurFrame = 0;
|
||||||
|
fCurTime = 0;
|
||||||
|
fDecoder = NULL;
|
||||||
|
fRawDecoder = NULL;
|
||||||
|
fExtractor = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -756,7 +771,8 @@ BMediaTrack::SetupWorkaround()
|
|||||||
be_roster->GetRunningAppInfo(tinfo.team, &ainfo);
|
be_roster->GetRunningAppInfo(tinfo.team, &ainfo);
|
||||||
|
|
||||||
if (strcmp(ainfo.signature, "application/x-vnd.marcone-soundplay") == 0) {
|
if (strcmp(ainfo.signature, "application/x-vnd.marcone-soundplay") == 0) {
|
||||||
fWorkaroundFlags = FORCE_RAW_AUDIO | FORCE_RAW_AUDIO_INT16_FORMAT | FORCE_RAW_AUDIO_HOST_ENDIAN;
|
fWorkaroundFlags = FORCE_RAW_AUDIO | FORCE_RAW_AUDIO_INT16_FORMAT
|
||||||
|
| FORCE_RAW_AUDIO_HOST_ENDIAN;
|
||||||
printf("BMediaTrack::SetupWorkaround: SoundPlay workaround active\n");
|
printf("BMediaTrack::SetupWorkaround: SoundPlay workaround active\n");
|
||||||
}
|
}
|
||||||
if (strcmp(ainfo.signature, "application/x-vnd.Be.MediaPlayer") == 0) {
|
if (strcmp(ainfo.signature, "application/x-vnd.Be.MediaPlayer") == 0) {
|
||||||
@@ -770,6 +786,7 @@ BMediaTrack::SetupWorkaround()
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool
|
bool
|
||||||
BMediaTrack::SetupFormatTranslation(const media_format &from, media_format *to)
|
BMediaTrack::SetupFormatTranslation(const media_format &from, media_format *to)
|
||||||
{
|
{
|
||||||
@@ -790,12 +807,16 @@ BMediaTrack::SetupFormatTranslation(const media_format &from, media_format *to)
|
|||||||
|
|
||||||
// XXX video?
|
// XXX video?
|
||||||
int buffer_size = from.u.raw_audio.buffer_size;
|
int buffer_size = from.u.raw_audio.buffer_size;
|
||||||
int frame_size = (from.u.raw_audio.format & 15) * from.u.raw_audio.channel_count;
|
int frame_size = (from.u.raw_audio.format & 15)
|
||||||
|
* from.u.raw_audio.channel_count;
|
||||||
media_format notconstFrom = from;
|
media_format notconstFrom = from;
|
||||||
|
|
||||||
ChunkProvider *chunkProvider = new(std::nothrow) RawDecoderChunkProvider(fDecoder, buffer_size, frame_size);
|
ChunkProvider *chunkProvider
|
||||||
|
= new(std::nothrow) RawDecoderChunkProvider(fDecoder, buffer_size,
|
||||||
|
frame_size);
|
||||||
if (!chunkProvider) {
|
if (!chunkProvider) {
|
||||||
ERROR("BMediaTrack::SetupFormatTranslation: can't create chunk provider\n");
|
ERROR("BMediaTrack::SetupFormatTranslation: can't create chunk "
|
||||||
|
"provider\n");
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
fRawDecoder->SetChunkProvider(chunkProvider);
|
fRawDecoder->SetChunkProvider(chunkProvider);
|
||||||
@@ -813,7 +834,8 @@ BMediaTrack::SetupFormatTranslation(const media_format &from, media_format *to)
|
|||||||
|
|
||||||
res = fRawDecoder->NegotiateOutputFormat(to);
|
res = fRawDecoder->NegotiateOutputFormat(to);
|
||||||
if (res != B_OK) {
|
if (res != B_OK) {
|
||||||
ERROR("BMediaTrack::SetupFormatTranslation: NegotiateOutputFormat failed\n");
|
ERROR("BMediaTrack::SetupFormatTranslation: NegotiateOutputFormat "
|
||||||
|
"failed\n");
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+112
-37
@@ -18,6 +18,32 @@
|
|||||||
#include "PluginManager.h"
|
#include "PluginManager.h"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
class MediaExtractorChunkWriter : public ChunkWriter {
|
||||||
|
public:
|
||||||
|
MediaExtractorChunkWriter(MediaWriter* writer, int32 streamIndex)
|
||||||
|
:
|
||||||
|
fWriter(writer),
|
||||||
|
fStreamIndex(streamIndex)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual status_t WriteChunk(const void* chunkBuffer, size_t chunkSize,
|
||||||
|
media_encode_info* encodeInfo)
|
||||||
|
{
|
||||||
|
return fWriter->WriteChunk(fStreamIndex, chunkBuffer, chunkSize,
|
||||||
|
encodeInfo);
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
MediaWriter* fWriter;
|
||||||
|
int32 fStreamIndex;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
// #pragma mark -
|
||||||
|
|
||||||
|
|
||||||
MediaWriter::MediaWriter(BDataIO* target, const media_file_format& fileFormat)
|
MediaWriter::MediaWriter(BDataIO* target, const media_file_format& fileFormat)
|
||||||
:
|
:
|
||||||
fTarget(target),
|
fTarget(target),
|
||||||
@@ -66,43 +92,6 @@ MediaWriter::GetFileFormatInfo(media_file_format* _fileFormat) const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
status_t
|
|
||||||
MediaWriter::WriteChunk(int32 streamIndex, const void* chunkBuffer,
|
|
||||||
size_t chunkSize, uint32 flags)
|
|
||||||
{
|
|
||||||
if (fWriter == NULL)
|
|
||||||
return B_NO_INIT;
|
|
||||||
|
|
||||||
StreamInfo* info;
|
|
||||||
if (!fStreamInfos.Get(streamIndex, &info))
|
|
||||||
return B_BAD_INDEX;
|
|
||||||
|
|
||||||
return fWriter->WriteChunk(info->cookie, chunkBuffer, chunkSize, flags);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
class MediaExtractorChunkWriter : public ChunkWriter {
|
|
||||||
public:
|
|
||||||
MediaExtractorChunkWriter(MediaWriter* writer, int32 streamIndex)
|
|
||||||
:
|
|
||||||
fWriter(writer),
|
|
||||||
fStreamIndex(streamIndex)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
virtual status_t WriteChunk(const void* chunkBuffer, size_t chunkSize,
|
|
||||||
uint32 flags)
|
|
||||||
{
|
|
||||||
return fWriter->WriteChunk(fStreamIndex, chunkBuffer, chunkSize,
|
|
||||||
flags);
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
|
||||||
MediaWriter* fWriter;
|
|
||||||
int32 fStreamIndex;
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
status_t
|
status_t
|
||||||
MediaWriter::CreateEncoder(Encoder** _encoder,
|
MediaWriter::CreateEncoder(Encoder** _encoder,
|
||||||
const media_codec_info* codecInfo, uint32 flags)
|
const media_codec_info* codecInfo, uint32 flags)
|
||||||
@@ -149,3 +138,89 @@ MediaWriter::CreateEncoder(Encoder** _encoder,
|
|||||||
|
|
||||||
return B_OK;
|
return B_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
status_t
|
||||||
|
MediaWriter::SetCopyright(const char* copyright)
|
||||||
|
{
|
||||||
|
if (fWriter == NULL)
|
||||||
|
return B_NO_INIT;
|
||||||
|
|
||||||
|
return fWriter->SetCopyright(copyright);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
status_t
|
||||||
|
MediaWriter::SetCopyright(int32 streamIndex, const char* copyright)
|
||||||
|
{
|
||||||
|
if (fWriter == NULL)
|
||||||
|
return B_NO_INIT;
|
||||||
|
|
||||||
|
StreamInfo* info;
|
||||||
|
if (!fStreamInfos.Get(streamIndex, &info))
|
||||||
|
return B_BAD_INDEX;
|
||||||
|
|
||||||
|
return fWriter->SetCopyright(info->cookie, copyright);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
status_t
|
||||||
|
MediaWriter::CommitHeader()
|
||||||
|
{
|
||||||
|
if (fWriter == NULL)
|
||||||
|
return B_NO_INIT;
|
||||||
|
|
||||||
|
return fWriter->CommitHeader();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
status_t
|
||||||
|
MediaWriter::Flush()
|
||||||
|
{
|
||||||
|
if (fWriter == NULL)
|
||||||
|
return B_NO_INIT;
|
||||||
|
|
||||||
|
return fWriter->Flush();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
status_t
|
||||||
|
MediaWriter::Close()
|
||||||
|
{
|
||||||
|
if (fWriter == NULL)
|
||||||
|
return B_NO_INIT;
|
||||||
|
|
||||||
|
return fWriter->Close();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
status_t
|
||||||
|
MediaWriter::AddTrackInfo(int32 streamIndex, uint32 code,
|
||||||
|
const void* data, size_t size, uint32 flags)
|
||||||
|
{
|
||||||
|
if (fWriter == NULL)
|
||||||
|
return B_NO_INIT;
|
||||||
|
|
||||||
|
StreamInfo* info;
|
||||||
|
if (!fStreamInfos.Get(streamIndex, &info))
|
||||||
|
return B_BAD_INDEX;
|
||||||
|
|
||||||
|
return fWriter->AddTrackInfo(info->cookie, code, data, size, flags);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
status_t
|
||||||
|
MediaWriter::WriteChunk(int32 streamIndex, const void* chunkBuffer,
|
||||||
|
size_t chunkSize, media_encode_info* encodeInfo)
|
||||||
|
{
|
||||||
|
if (fWriter == NULL)
|
||||||
|
return B_NO_INIT;
|
||||||
|
|
||||||
|
StreamInfo* info;
|
||||||
|
if (!fStreamInfos.Get(streamIndex, &info))
|
||||||
|
return B_BAD_INDEX;
|
||||||
|
|
||||||
|
return fWriter->WriteChunk(info->cookie, chunkBuffer, chunkSize,
|
||||||
|
encodeInfo);
|
||||||
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user