SourceBufferPrivateGStreamer.cpp [plain text]
#include "config.h"
#include "SourceBufferPrivateGStreamer.h"
#if ENABLE(MEDIA_SOURCE) && USE(GSTREAMER)
#include "ContentType.h"
#include "GStreamerUtilities.h"
#include "MediaPlayerPrivateGStreamerMSE.h"
#include "MediaSample.h"
#include "MediaSourceClientGStreamerMSE.h"
#include "MediaSourceGStreamer.h"
#include "NotImplemented.h"
#include "WebKitMediaSourceGStreamer.h"
namespace WebCore {
Ref<SourceBufferPrivateGStreamer> SourceBufferPrivateGStreamer::create(MediaSourceGStreamer* mediaSource, Ref<MediaSourceClientGStreamerMSE> client, const ContentType& contentType)
{
return adoptRef(*new SourceBufferPrivateGStreamer(mediaSource, client.get(), contentType));
}
SourceBufferPrivateGStreamer::SourceBufferPrivateGStreamer(MediaSourceGStreamer* mediaSource, Ref<MediaSourceClientGStreamerMSE> client, const ContentType& contentType)
: SourceBufferPrivate()
, m_mediaSource(mediaSource)
, m_type(contentType)
, m_client(client.get())
{
}
void SourceBufferPrivateGStreamer::setClient(SourceBufferPrivateClient* client)
{
m_sourceBufferPrivateClient = client;
}
void SourceBufferPrivateGStreamer::append(const unsigned char* data, unsigned length)
{
ASSERT(m_mediaSource);
if (!m_sourceBufferPrivateClient)
return;
if (m_client->append(this, data, length))
return;
m_sourceBufferPrivateClient->sourceBufferPrivateAppendComplete(this, SourceBufferPrivateClient::ReadStreamFailed);
}
void SourceBufferPrivateGStreamer::abort()
{
m_client->abort(this);
}
void SourceBufferPrivateGStreamer::resetParserState()
{
m_client->resetParserState(this);
}
void SourceBufferPrivateGStreamer::removedFromMediaSource()
{
if (m_mediaSource)
m_mediaSource->removeSourceBuffer(this);
m_client->removedFromMediaSource(this);
}
MediaPlayer::ReadyState SourceBufferPrivateGStreamer::readyState() const
{
return m_mediaSource->readyState();
}
void SourceBufferPrivateGStreamer::setReadyState(MediaPlayer::ReadyState state)
{
m_mediaSource->setReadyState(state);
}
void SourceBufferPrivateGStreamer::flush(AtomicString trackId)
{
m_client->flush(trackId);
}
void SourceBufferPrivateGStreamer::enqueueSample(PassRefPtr<MediaSample> prpSample, AtomicString)
{
m_notifyWhenReadyForMoreSamples = false;
RefPtr<MediaSample> protectedPrpSample = prpSample;
m_client->enqueueSample(protectedPrpSample);
}
bool SourceBufferPrivateGStreamer::isReadyForMoreSamples(AtomicString)
{
return m_isReadyForMoreSamples;
}
void SourceBufferPrivateGStreamer::setReadyForMoreSamples(bool isReady)
{
ASSERT(WTF::isMainThread());
m_isReadyForMoreSamples = isReady;
}
void SourceBufferPrivateGStreamer::notifyReadyForMoreSamples()
{
ASSERT(WTF::isMainThread());
setReadyForMoreSamples(true);
if (m_notifyWhenReadyForMoreSamples)
m_sourceBufferPrivateClient->sourceBufferPrivateDidBecomeReadyForMoreSamples(this, m_trackId);
}
void SourceBufferPrivateGStreamer::setActive(bool isActive)
{
if (m_mediaSource)
m_mediaSource->sourceBufferPrivateDidChangeActiveState(this, isActive);
}
void SourceBufferPrivateGStreamer::stopAskingForMoreSamples(AtomicString)
{
notImplemented();
}
void SourceBufferPrivateGStreamer::notifyClientWhenReadyForMoreSamples(AtomicString trackId)
{
ASSERT(WTF::isMainThread());
m_notifyWhenReadyForMoreSamples = true;
m_trackId = trackId;
}
void SourceBufferPrivateGStreamer::didReceiveInitializationSegment(const SourceBufferPrivateClient::InitializationSegment& initializationSegment)
{
if (m_sourceBufferPrivateClient)
m_sourceBufferPrivateClient->sourceBufferPrivateDidReceiveInitializationSegment(this, initializationSegment);
}
void SourceBufferPrivateGStreamer::didReceiveSample(PassRefPtr<MediaSample> prpSample)
{
RefPtr<MediaSample> protectedPrpSample = prpSample;
if (m_sourceBufferPrivateClient)
m_sourceBufferPrivateClient->sourceBufferPrivateDidReceiveSample(this, *protectedPrpSample);
}
void SourceBufferPrivateGStreamer::didReceiveAllPendingSamples()
{
if (m_sourceBufferPrivateClient)
m_sourceBufferPrivateClient->sourceBufferPrivateAppendComplete(this, SourceBufferPrivateClient::AppendSucceeded);
}
}
#endif