PluginManager/AddOnManager: Add streamers support code
This commit is contained in:
@@ -14,6 +14,7 @@
|
|||||||
#include "DecoderPlugin.h"
|
#include "DecoderPlugin.h"
|
||||||
#include "EncoderPlugin.h"
|
#include "EncoderPlugin.h"
|
||||||
#include "ReaderPlugin.h"
|
#include "ReaderPlugin.h"
|
||||||
|
#include "StreamerPlugin.h"
|
||||||
#include "WriterPlugin.h"
|
#include "WriterPlugin.h"
|
||||||
|
|
||||||
#include <TList.h>
|
#include <TList.h>
|
||||||
@@ -59,6 +60,10 @@ public:
|
|||||||
|
|
||||||
void DestroyEncoder(Encoder* encoder);
|
void DestroyEncoder(Encoder* encoder);
|
||||||
|
|
||||||
|
status_t CreateStreamer(Streamer** streamer,
|
||||||
|
BUrl* url, BDataIO** source);
|
||||||
|
void DestroyStreamer(Streamer* streamer);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
status_t _LoadPlugin(const entry_ref& ref,
|
status_t _LoadPlugin(const entry_ref& ref,
|
||||||
MediaPlugin** plugin, image_id* image);
|
MediaPlugin** plugin, image_id* image);
|
||||||
|
|||||||
@@ -203,6 +203,23 @@ AddOnManager::GetReaders(entry_ref* outRefs, int32* outCount,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
status_t
|
||||||
|
AddOnManager::GetStreamers(entry_ref* outRefs, int32* outCount,
|
||||||
|
int32 maxCount)
|
||||||
|
{
|
||||||
|
BAutolock locker(fLock);
|
||||||
|
RegisterAddOns();
|
||||||
|
|
||||||
|
streamer_info* info;
|
||||||
|
for (fStreamerList.Rewind(); fStreamerList.GetNext(&info);) {
|
||||||
|
*outRefs = info->ref;
|
||||||
|
outRefs++;
|
||||||
|
}
|
||||||
|
|
||||||
|
return B_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
status_t
|
status_t
|
||||||
AddOnManager::GetEncoder(entry_ref* _encoderRef, int32 id)
|
AddOnManager::GetEncoder(entry_ref* _encoderRef, int32 id)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -45,6 +45,9 @@ public:
|
|||||||
status_t GetReaders(entry_ref* _ref,
|
status_t GetReaders(entry_ref* _ref,
|
||||||
int32* _count, int32 maxCount);
|
int32* _count, int32 maxCount);
|
||||||
|
|
||||||
|
status_t GetStreamers(entry_ref* _ref,
|
||||||
|
int32* _count, int32 maxCount);
|
||||||
|
|
||||||
status_t GetEncoder(entry_ref* _ref, int32 id);
|
status_t GetEncoder(entry_ref* _ref, int32 id);
|
||||||
|
|
||||||
status_t GetWriter(entry_ref* _ref,
|
status_t GetWriter(entry_ref* _ref,
|
||||||
|
|||||||
@@ -20,6 +20,7 @@
|
|||||||
PluginManager gPluginManager;
|
PluginManager gPluginManager;
|
||||||
|
|
||||||
#define BLOCK_SIZE 4096
|
#define BLOCK_SIZE 4096
|
||||||
|
#define MAX_STREAMERS 40
|
||||||
|
|
||||||
|
|
||||||
class BMediaIOWrapper : public BMediaIO {
|
class BMediaIOWrapper : public BMediaIO {
|
||||||
@@ -580,6 +581,79 @@ PluginManager::DestroyEncoder(Encoder* encoder)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
status_t
|
||||||
|
PluginManager::CreateStreamer(Streamer** streamer, BUrl* url, BDataIO** source)
|
||||||
|
{
|
||||||
|
TRACE("PluginManager::CreateStreamer enter\n");
|
||||||
|
|
||||||
|
entry_ref refs[MAX_STREAMERS];
|
||||||
|
int32 count;
|
||||||
|
|
||||||
|
status_t ret = AddOnManager::GetInstance()->GetStreamers(refs, &count,
|
||||||
|
MAX_STREAMERS);
|
||||||
|
if (ret != B_OK) {
|
||||||
|
printf("PluginManager::CreateStreamer: can't get list of readers: %s\n",
|
||||||
|
strerror(ret));
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
// try each reader by calling it's Sniff function...
|
||||||
|
for (int32 i = 0; i < count; i++) {
|
||||||
|
entry_ref ref = refs[i];
|
||||||
|
MediaPlugin* plugin = GetPlugin(ref);
|
||||||
|
if (plugin == NULL) {
|
||||||
|
printf("PluginManager::CreateStreamer: GetPlugin failed\n");
|
||||||
|
return B_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
|
StreamerPlugin* streamerPlugin = dynamic_cast<StreamerPlugin*>(plugin);
|
||||||
|
if (streamerPlugin == NULL) {
|
||||||
|
printf("PluginManager::CreateStreamer: dynamic_cast failed\n");
|
||||||
|
PutPlugin(plugin);
|
||||||
|
return B_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
|
*streamer = streamerPlugin->NewStreamer();
|
||||||
|
if (*streamer == NULL) {
|
||||||
|
printf("PluginManager::CreateStreamer: NewReader failed\n");
|
||||||
|
PutPlugin(plugin);
|
||||||
|
return B_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
|
(*streamer)->fMediaPlugin = plugin;
|
||||||
|
|
||||||
|
BMediaIO* streamSource = NULL;
|
||||||
|
if ((*streamer)->Sniff(url, &streamSource) == B_OK) {
|
||||||
|
TRACE("PluginManager::CreateStreamer: Sniff success ");
|
||||||
|
*source = streamSource;
|
||||||
|
return B_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
DestroyStreamer(*streamer);
|
||||||
|
*streamer = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
TRACE("PluginManager::CreateStreamer leave\n");
|
||||||
|
return B_MEDIA_NO_HANDLER;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
PluginManager::DestroyStreamer(Streamer* streamer)
|
||||||
|
{
|
||||||
|
if (streamer != NULL) {
|
||||||
|
TRACE("PluginManager::DestroyStreamer(%p, plugin: %p)\n", streamer,
|
||||||
|
streamer->fMediaPlugin);
|
||||||
|
// NOTE: We have to put the plug-in after deleting the encoder,
|
||||||
|
// since otherwise we may actually unload the code for the
|
||||||
|
// destructor...
|
||||||
|
MediaPlugin* plugin = streamer->fMediaPlugin;
|
||||||
|
delete streamer;
|
||||||
|
PutPlugin(plugin);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// #pragma mark -
|
// #pragma mark -
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,8 +1,14 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2016, Dario Casalinuovo. All rights reserved.
|
||||||
|
* Distributed under the terms of the MIT License.
|
||||||
|
*/
|
||||||
|
|
||||||
#include "StreamerPlugin.h"
|
#include "StreamerPlugin.h"
|
||||||
|
|
||||||
|
|
||||||
Streamer::Streamer()
|
Streamer::Streamer()
|
||||||
|
:
|
||||||
|
fMediaPlugin(NULL)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -12,33 +18,8 @@ Streamer::~Streamer()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void Streamer::_ReservedStreamer1() {}
|
||||||
Streamer::_ReservedStreamer1()
|
void Streamer::_ReservedStreamer2() {}
|
||||||
{
|
void Streamer::_ReservedStreamer3() {}
|
||||||
}
|
void Streamer::_ReservedStreamer4() {}
|
||||||
|
void Streamer::_ReservedStreamer5() {}
|
||||||
|
|
||||||
void
|
|
||||||
Streamer::_ReservedStreamer2()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void
|
|
||||||
Streamer::_ReservedStreamer3()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void
|
|
||||||
Streamer::_ReservedStreamer4()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void
|
|
||||||
Streamer::_ReservedStreamer5()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|||||||
Reference in New Issue
Block a user