MediaStreamer: Extend API to support DVD navigation
* This is a general review of the code and includes a rework of the sniffing API.
This commit is contained in:
parent
d18fe1c54c
commit
662583b300
@ -44,7 +44,7 @@ public:
|
||||
static void ReleaseEncoder(BEncoder* encoder);
|
||||
|
||||
static status_t InstantiateStreamer(BStreamer** streamer,
|
||||
BUrl url, BDataIO** source);
|
||||
BUrl url);
|
||||
static void ReleaseStreamer(BStreamer* streamer);
|
||||
|
||||
static status_t GetDecoderInfo(BDecoder* decoder,
|
||||
|
@ -11,6 +11,7 @@
|
||||
|
||||
|
||||
#include <Decoder.h>
|
||||
#include <MediaStreamer.h>
|
||||
#include <Reader.h>
|
||||
|
||||
|
||||
@ -23,6 +24,8 @@ struct stream_info;
|
||||
class BMediaExtractor {
|
||||
public:
|
||||
BMediaExtractor(BDataIO* source, int32 flags);
|
||||
// TODO
|
||||
//BMediaExtractor(BMediaStreamer* streamer);
|
||||
~BMediaExtractor();
|
||||
|
||||
status_t InitCheck();
|
||||
|
@ -6,6 +6,7 @@
|
||||
#define _MEDIA_STREAMER_H
|
||||
|
||||
|
||||
#include <MediaIO.h>
|
||||
#include <Streamer.h>
|
||||
#include <Url.h>
|
||||
|
||||
@ -18,11 +19,34 @@ public:
|
||||
BMediaStreamer(BUrl url);
|
||||
~BMediaStreamer();
|
||||
|
||||
status_t CreateAdapter(BDataIO** adapter);
|
||||
status_t InitCheck() const;
|
||||
|
||||
// TODO: So, it seems since this API was not public,
|
||||
// the memory ownership is leaved to class users.
|
||||
// See if this fits our plans, and eventually, move
|
||||
// this memory management from BMediaFile to BMediaExtractor,
|
||||
// BMediaWriter and BMediaStreamer.
|
||||
BMediaIO* Adapter() const;
|
||||
|
||||
// TODO: Don't we need an open in the extractor and writer?
|
||||
status_t Open();
|
||||
void Close();
|
||||
bool IsOpened() const;
|
||||
|
||||
//uint32 Capabilities() const;
|
||||
//status_t GetMetaData(BMetaData* data) const;
|
||||
//status_t SetHandler(BHandler* handler);
|
||||
//BHandler* Handler() const;
|
||||
|
||||
void MouseMoved(uint32 x, uint32 y);
|
||||
void MouseDown(uint32 x, uint32 y);
|
||||
|
||||
private:
|
||||
BUrl fUrl;
|
||||
BStreamer* fStreamer;
|
||||
status_t fInitCheck;
|
||||
|
||||
bool fOpened;
|
||||
|
||||
// No virtual padding needed. Looks like a design decision.
|
||||
// Let's respect that, for now.
|
||||
|
@ -20,7 +20,12 @@ namespace BPrivate {
|
||||
|
||||
class BStreamer {
|
||||
public:
|
||||
virtual status_t Sniff(const BUrl& url, BDataIO** source) = 0;
|
||||
virtual status_t Sniff(const BUrl& url) = 0;
|
||||
virtual BMediaIO* Adapter() const = 0;
|
||||
|
||||
// Base impl does nothing
|
||||
virtual void MouseMoved(uint32 x, uint32 y);
|
||||
virtual void MouseDown(uint32 x, uint32 y);
|
||||
|
||||
protected:
|
||||
BStreamer();
|
||||
|
@ -101,10 +101,9 @@ BCodecRoster::ReleaseEncoder(BEncoder* encoder)
|
||||
|
||||
|
||||
status_t
|
||||
BCodecRoster::InstantiateStreamer(BStreamer** streamer, BUrl url,
|
||||
BDataIO** source)
|
||||
BCodecRoster::InstantiateStreamer(BStreamer** streamer, BUrl url)
|
||||
{
|
||||
return gPluginManager.CreateStreamer(streamer, url, source);
|
||||
return gPluginManager.CreateStreamer(streamer, url);
|
||||
}
|
||||
|
||||
|
||||
|
@ -6,11 +6,12 @@
|
||||
|
||||
#include "MediaStreamer.h"
|
||||
|
||||
#include <CodecRoster.h>
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "MediaDebug.h"
|
||||
|
||||
#include "PluginManager.h"
|
||||
|
||||
|
||||
@ -19,11 +20,14 @@ namespace BCodecKit {
|
||||
|
||||
BMediaStreamer::BMediaStreamer(BUrl url)
|
||||
:
|
||||
fStreamer(NULL)
|
||||
fUrl(url),
|
||||
fStreamer(NULL),
|
||||
fInitCheck(B_OK),
|
||||
fOpened(false)
|
||||
{
|
||||
// TODO: ideally we should see if the url IsValid() and
|
||||
// matches our protocol.
|
||||
CALLED();
|
||||
|
||||
fUrl = url;
|
||||
}
|
||||
|
||||
|
||||
@ -31,22 +35,67 @@ BMediaStreamer::~BMediaStreamer()
|
||||
{
|
||||
CALLED();
|
||||
|
||||
if (fStreamer != NULL)
|
||||
gPluginManager.DestroyStreamer(fStreamer);
|
||||
if (fOpened)
|
||||
Close();
|
||||
}
|
||||
|
||||
|
||||
status_t
|
||||
BMediaStreamer::CreateAdapter(BDataIO** adapter)
|
||||
BMediaStreamer::InitCheck() const
|
||||
{
|
||||
return fInitCheck;
|
||||
}
|
||||
|
||||
|
||||
status_t
|
||||
BMediaStreamer::Open()
|
||||
{
|
||||
CALLED();
|
||||
|
||||
fOpened = true;
|
||||
|
||||
// NOTE: Consider splitting the streamer creation and
|
||||
// sniff in PluginManager.
|
||||
if (fStreamer != NULL)
|
||||
gPluginManager.DestroyStreamer(fStreamer);
|
||||
BCodecRoster::ReleaseStreamer(fStreamer);
|
||||
|
||||
return gPluginManager.CreateStreamer(&fStreamer, fUrl, adapter);
|
||||
return BCodecRoster::InstantiateStreamer(&fStreamer, fUrl);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
BMediaStreamer::Close()
|
||||
{
|
||||
if (fStreamer != NULL)
|
||||
BCodecRoster::ReleaseStreamer(fStreamer);
|
||||
}
|
||||
|
||||
|
||||
bool
|
||||
BMediaStreamer::IsOpened() const
|
||||
{
|
||||
return fOpened;
|
||||
}
|
||||
|
||||
|
||||
BMediaIO*
|
||||
BMediaStreamer::Adapter() const
|
||||
{
|
||||
return fStreamer->Adapter();
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
BMediaStreamer::MouseMoved(uint32 x, uint32 y)
|
||||
{
|
||||
fStreamer->MouseMoved(x, y);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
BMediaStreamer::MouseDown(uint32 x, uint32 y)
|
||||
{
|
||||
fStreamer->MouseDown(x, y);
|
||||
}
|
||||
|
||||
|
||||
|
@ -602,7 +602,7 @@ PluginManager::DestroyEncoder(BEncoder* encoder)
|
||||
|
||||
|
||||
status_t
|
||||
PluginManager::CreateStreamer(BStreamer** streamer, BUrl url, BDataIO** source)
|
||||
PluginManager::CreateStreamer(BStreamer** streamer, BUrl url)
|
||||
{
|
||||
BAutolock _(fLocker);
|
||||
|
||||
@ -645,10 +645,8 @@ PluginManager::CreateStreamer(BStreamer** streamer, BUrl url, BDataIO** source)
|
||||
(*streamer)->fMediaPlugin = plugin;
|
||||
plugin->fRefCount++;
|
||||
|
||||
BDataIO* streamSource = NULL;
|
||||
if ((*streamer)->Sniff(url, &streamSource) == B_OK) {
|
||||
if ((*streamer)->Sniff(url) == B_OK) {
|
||||
TRACE("PluginManager::CreateStreamer: Sniff success\n");
|
||||
*source = streamSource;
|
||||
return B_OK;
|
||||
}
|
||||
|
||||
|
@ -22,6 +22,18 @@ BStreamer::~BStreamer()
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
BStreamer::MouseMoved(uint32 x, uint32 y)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
BStreamer::MouseDown(uint32 x, uint32 y)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
void BStreamer::_ReservedStreamer1() {}
|
||||
void BStreamer::_ReservedStreamer2() {}
|
||||
void BStreamer::_ReservedStreamer3() {}
|
||||
|
@ -604,7 +604,8 @@ BMediaFile::_InitStreamer(const BUrl& url, BDataIO** adapter)
|
||||
return;
|
||||
}
|
||||
|
||||
fErr = fStreamer->CreateAdapter(adapter);
|
||||
fErr = fStreamer->Open();
|
||||
*adapter = fStreamer->Adapter();
|
||||
}
|
||||
|
||||
/*
|
||||
|
Loading…
x
Reference in New Issue
Block a user