This source file includes following definitions.
- media_message_loop_
- GetNextDemuxerClientID
- AddDelegate
- RemoveDelegate
- OnMessageReceived
- DemuxerReady
- ReadFromDemuxerAck
- DemuxerSeekDone
- DurationChanged
- DispatchMessage
- OnReadFromDemuxer
- OnDemuxerSeekRequest
- OnMediaConfigRequest
#include "content/renderer/media/android/renderer_demuxer_android.h"
#include "base/bind.h"
#include "base/message_loop/message_loop.h"
#include "content/child/thread_safe_sender.h"
#include "content/common/media/media_player_messages_android.h"
#include "content/renderer/media/android/media_source_delegate.h"
#include "content/renderer/media/android/renderer_media_player_manager.h"
#include "content/renderer/media/android/webmediaplayer_android.h"
#include "content/renderer/render_thread_impl.h"
namespace content {
RendererDemuxerAndroid::RendererDemuxerAndroid()
: thread_safe_sender_(RenderThreadImpl::current()->thread_safe_sender()),
media_message_loop_(
RenderThreadImpl::current()->GetMediaThreadMessageLoopProxy()) {}
RendererDemuxerAndroid::~RendererDemuxerAndroid() {}
int RendererDemuxerAndroid::GetNextDemuxerClientID() {
return next_demuxer_client_id_.GetNext() + 1;
}
void RendererDemuxerAndroid::AddDelegate(int demuxer_client_id,
MediaSourceDelegate* delegate) {
DCHECK(media_message_loop_->BelongsToCurrentThread());
delegates_.AddWithID(delegate, demuxer_client_id);
}
void RendererDemuxerAndroid::RemoveDelegate(int demuxer_client_id) {
DCHECK(media_message_loop_->BelongsToCurrentThread());
delegates_.Remove(demuxer_client_id);
}
bool RendererDemuxerAndroid::OnMessageReceived(const IPC::Message& message) {
switch (message.type()) {
case MediaPlayerMsg_DemuxerSeekRequest::ID:
case MediaPlayerMsg_ReadFromDemuxer::ID:
case MediaPlayerMsg_MediaConfigRequest::ID:
media_message_loop_->PostTask(FROM_HERE, base::Bind(
&RendererDemuxerAndroid::DispatchMessage, this, message));
return true;
}
return false;
}
void RendererDemuxerAndroid::DemuxerReady(
int demuxer_client_id,
const media::DemuxerConfigs& configs) {
thread_safe_sender_->Send(new MediaPlayerHostMsg_DemuxerReady(
demuxer_client_id, configs));
}
void RendererDemuxerAndroid::ReadFromDemuxerAck(
int demuxer_client_id,
const media::DemuxerData& data) {
thread_safe_sender_->Send(new MediaPlayerHostMsg_ReadFromDemuxerAck(
demuxer_client_id, data));
}
void RendererDemuxerAndroid::DemuxerSeekDone(
int demuxer_client_id,
const base::TimeDelta& actual_browser_seek_time) {
thread_safe_sender_->Send(new MediaPlayerHostMsg_DemuxerSeekDone(
demuxer_client_id, actual_browser_seek_time));
}
void RendererDemuxerAndroid::DurationChanged(int demuxer_client_id,
const base::TimeDelta& duration) {
thread_safe_sender_->Send(new MediaPlayerHostMsg_DurationChanged(
demuxer_client_id, duration));
}
void RendererDemuxerAndroid::DispatchMessage(const IPC::Message& message) {
IPC_BEGIN_MESSAGE_MAP(RendererDemuxerAndroid, message)
IPC_MESSAGE_HANDLER(MediaPlayerMsg_DemuxerSeekRequest, OnDemuxerSeekRequest)
IPC_MESSAGE_HANDLER(MediaPlayerMsg_ReadFromDemuxer, OnReadFromDemuxer)
IPC_MESSAGE_HANDLER(MediaPlayerMsg_MediaConfigRequest, OnMediaConfigRequest)
IPC_END_MESSAGE_MAP()
}
void RendererDemuxerAndroid::OnReadFromDemuxer(
int demuxer_client_id,
media::DemuxerStream::Type type) {
MediaSourceDelegate* delegate = delegates_.Lookup(demuxer_client_id);
if (delegate)
delegate->OnReadFromDemuxer(type);
}
void RendererDemuxerAndroid::OnDemuxerSeekRequest(
int demuxer_client_id,
const base::TimeDelta& time_to_seek,
bool is_browser_seek) {
MediaSourceDelegate* delegate = delegates_.Lookup(demuxer_client_id);
if (delegate)
delegate->Seek(time_to_seek, is_browser_seek);
}
void RendererDemuxerAndroid::OnMediaConfigRequest(int demuxer_client_id) {
MediaSourceDelegate* delegate = delegates_.Lookup(demuxer_client_id);
if (delegate)
delegate->OnMediaConfigRequest();
}
}