Stubbed out implementation of an Encoder and EncoderPlugin. This will probably
need to work differently, such that supported media_formats come into play, I will know soon when I implement some of the stuff from MediaFormats.h. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@31994 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -0,0 +1,81 @@
|
||||
/*
|
||||
* Copyright 2009, Stephan Amßus <[email protected]>
|
||||
* All rights reserved. Distributed under the terms of the MIT license.
|
||||
*/
|
||||
|
||||
|
||||
#include "AVCodecEncoder.h"
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
|
||||
#undef TRACE
|
||||
#define TRACE_AV_CODEC_ENCODER
|
||||
#ifdef TRACE_AV_CODEC_ENCODER
|
||||
# define TRACE(x...) printf(x)
|
||||
#else
|
||||
# define TRACE(x...)
|
||||
#endif
|
||||
|
||||
|
||||
AVCodecEncoder::AVCodecEncoder(const char* shortName)
|
||||
:
|
||||
Encoder()
|
||||
{
|
||||
TRACE("AVCodecEncoder::AVCodecEncoder()\n");
|
||||
}
|
||||
|
||||
|
||||
AVCodecEncoder::~AVCodecEncoder()
|
||||
{
|
||||
TRACE("AVCodecEncoder::~AVCodecEncoder()\n");
|
||||
}
|
||||
|
||||
|
||||
status_t
|
||||
AVCodecEncoder::SetFormat(const media_file_format& fileFormat,
|
||||
media_format* _inOutEncodedFormat)
|
||||
{
|
||||
TRACE("AVCodecEncoder::SetFormat()\n");
|
||||
|
||||
return B_NOT_SUPPORTED;
|
||||
}
|
||||
|
||||
|
||||
status_t
|
||||
AVCodecEncoder::AddTrackInfo(uint32 code, const void* data, size_t size,
|
||||
uint32 flags)
|
||||
{
|
||||
TRACE("AVCodecEncoder::AddTrackInfo(%lu, %p, %ld, %lu)\n", code, data,
|
||||
size, flags);
|
||||
|
||||
return B_NOT_SUPPORTED;
|
||||
}
|
||||
|
||||
|
||||
status_t
|
||||
AVCodecEncoder::GetEncodeParameters(encode_parameters* parameters) const
|
||||
{
|
||||
TRACE("AVCodecEncoder::GetEncodeParameters(%p)\n", parameters);
|
||||
|
||||
return B_NOT_SUPPORTED;
|
||||
}
|
||||
|
||||
|
||||
status_t
|
||||
AVCodecEncoder::SetEncodeParameters(encode_parameters* parameters) const
|
||||
{
|
||||
TRACE("AVCodecEncoder::SetEncodeParameters(%p)\n", parameters);
|
||||
|
||||
return B_NOT_SUPPORTED;
|
||||
}
|
||||
|
||||
|
||||
status_t
|
||||
AVCodecEncoder::Encode(const void* buffer, int64 frameCount,
|
||||
media_encode_info* info)
|
||||
{
|
||||
TRACE("AVCodecEncoder::Encode(%p, %lld, %p)\n", buffer, frameCount, info);
|
||||
|
||||
return B_NOT_SUPPORTED;
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
/*
|
||||
* Copyright 2009, Stephan Aßmus <[email protected]>.
|
||||
* All rights reserved. Distributed under the terms of the MIT license.
|
||||
*/
|
||||
#ifndef AVCODEC_ENCODER_H
|
||||
#define AVCODEC_ENCODER_H
|
||||
|
||||
|
||||
#include <MediaFormats.h>
|
||||
|
||||
#include "EncoderPlugin.h"
|
||||
|
||||
|
||||
class AVCodecEncoder : public Encoder {
|
||||
public:
|
||||
AVCodecEncoder(const char* shortName);
|
||||
|
||||
virtual ~AVCodecEncoder();
|
||||
|
||||
virtual status_t SetFormat(const media_file_format& fileFormat,
|
||||
media_format* _inOutEncodedFormat);
|
||||
|
||||
virtual status_t AddTrackInfo(uint32 code, const void* data,
|
||||
size_t size, uint32 flags = 0);
|
||||
|
||||
virtual status_t GetEncodeParameters(
|
||||
encode_parameters* parameters) const;
|
||||
virtual status_t SetEncodeParameters(
|
||||
encode_parameters* parameters) const;
|
||||
|
||||
virtual status_t Encode(const void* buffer, int64 frameCount,
|
||||
media_encode_info* info);
|
||||
|
||||
private:
|
||||
};
|
||||
|
||||
#endif // AVCODEC_ENCODER_H
|
||||
@@ -0,0 +1,28 @@
|
||||
/*
|
||||
* Copyright 2009 Stephan Aßmus <[email protected]>
|
||||
* All rights reserved. Distributed under the terms of the MIT license.
|
||||
*/
|
||||
|
||||
|
||||
#include "EncoderTable.h"
|
||||
|
||||
|
||||
const media_codec_info gEncoderTable[] = {
|
||||
{
|
||||
"MPEG2 Video",
|
||||
"mpeg2video",
|
||||
0,
|
||||
0,
|
||||
{ 0 }
|
||||
},
|
||||
{
|
||||
"WAV",
|
||||
"wav",
|
||||
0,
|
||||
0,
|
||||
{ 0 }
|
||||
},
|
||||
};
|
||||
|
||||
const size_t gEncoderCount = sizeof(gEncoderTable) / sizeof(media_codec_info);
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
/*
|
||||
* Copyright 2009 Stephan Aßmus <[email protected]>
|
||||
* All rights reserved. Distributed under the terms of the MIT license.
|
||||
*/
|
||||
#ifndef ENCODER_TABLE_H
|
||||
#define ENCODER_TABLE_H
|
||||
|
||||
|
||||
#include <MediaFormats.h>
|
||||
|
||||
|
||||
extern const media_codec_info gEncoderTable[];
|
||||
extern const size_t gEncoderCount;
|
||||
|
||||
|
||||
#endif // ENCODER_TABLE_H
|
||||
@@ -21,9 +21,11 @@ extern "C" {
|
||||
}
|
||||
|
||||
#include "AVCodecDecoder.h"
|
||||
#include "AVCodecEncoder.h"
|
||||
#include "AVFormatReader.h"
|
||||
#include "AVFormatWriter.h"
|
||||
#include "CodecTable.h"
|
||||
#include "EncoderTable.h"
|
||||
#include "MuxerTable.h"
|
||||
|
||||
|
||||
@@ -129,6 +131,26 @@ FFmpegPlugin::GetSupportedFileFormats(const media_file_format** _fileFormats,
|
||||
}
|
||||
|
||||
|
||||
Encoder*
|
||||
FFmpegPlugin::NewEncoder(const media_codec_info& codecInfo)
|
||||
{
|
||||
return new(std::nothrow)AVCodecEncoder(codecInfo.short_name);
|
||||
}
|
||||
|
||||
|
||||
status_t
|
||||
FFmpegPlugin::GetSupportedCodecs(const media_codec_info** _codecInfos,
|
||||
size_t* _count)
|
||||
{
|
||||
*_codecInfos = gEncoderTable;
|
||||
*_count = gEncoderCount;
|
||||
return B_OK;
|
||||
}
|
||||
|
||||
|
||||
// #pragma mark -
|
||||
|
||||
|
||||
MediaPlugin*
|
||||
instantiate_plugin()
|
||||
{
|
||||
|
||||
@@ -6,20 +6,20 @@
|
||||
*
|
||||
* Distributed under the terms of the MIT License.
|
||||
*/
|
||||
|
||||
//! libavcodec based decoder for Haiku
|
||||
|
||||
#ifndef FFMPEG_PLUGIN_H
|
||||
#define FFMPEG_PLUGIN_H
|
||||
|
||||
|
||||
#include <MediaFormats.h>
|
||||
|
||||
#include "DecoderPlugin.h"
|
||||
#include "EncoderPlugin.h"
|
||||
#include "ReaderPlugin.h"
|
||||
#include "WriterPlugin.h"
|
||||
|
||||
|
||||
class FFmpegPlugin : public ReaderPlugin, public DecoderPlugin,
|
||||
public WriterPlugin {
|
||||
public WriterPlugin, public EncoderPlugin {
|
||||
public:
|
||||
virtual Reader* NewReader();
|
||||
|
||||
@@ -32,6 +32,12 @@ public:
|
||||
const media_file_format** _fileFormats,
|
||||
size_t* _count);
|
||||
|
||||
virtual Encoder* NewEncoder(
|
||||
const media_codec_info& codecInfo);
|
||||
virtual status_t GetSupportedCodecs(
|
||||
const media_codec_info** codecInfos,
|
||||
size_t* count);
|
||||
|
||||
private:
|
||||
class GlobalInitilizer {
|
||||
public:
|
||||
|
||||
@@ -11,10 +11,12 @@ SubDirHdrs [ FDirName $(SUBDIR) libswscale ] ;
|
||||
|
||||
Addon ffmpeg :
|
||||
AVCodecDecoder.cpp
|
||||
AVCodecEncoder.cpp
|
||||
AVFormatReader.cpp
|
||||
AVFormatWriter.cpp
|
||||
CodecTable.cpp
|
||||
DemuxerTable.cpp
|
||||
EncoderTable.cpp
|
||||
FFmpegPlugin.cpp
|
||||
MuxerTable.cpp
|
||||
|
||||
|
||||
Reference in New Issue
Block a user