Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(267)

Unified Diff: chrome/renderer/media/cast_session_delegate.cc

Issue 883293005: Cast: Basic cast_receiver API for chrome. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: removed extra BUILD.gn line Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/renderer/media/cast_session_delegate.cc
diff --git a/chrome/renderer/media/cast_session_delegate.cc b/chrome/renderer/media/cast_session_delegate.cc
index 4be9fe3ba02ca593dcf6d86fe87406ea2a74ee8c..6a0da851835b11cef2b727f2b83222923474accf 100644
--- a/chrome/renderer/media/cast_session_delegate.cc
+++ b/chrome/renderer/media/cast_session_delegate.cc
@@ -31,13 +31,57 @@ using media::cast::VideoSenderConfig;
static base::LazyInstance<CastThreads> g_cast_threads =
LAZY_INSTANCE_INITIALIZER;
-CastSessionDelegate::CastSessionDelegate()
+CastSessionDelegateBase::CastSessionDelegateBase()
: io_message_loop_proxy_(
content::RenderThread::Get()->GetIOMessageLoopProxy()),
weak_factory_(this) {
DCHECK(io_message_loop_proxy_.get());
}
+CastSessionDelegateBase::~CastSessionDelegateBase() {
+ DCHECK(io_message_loop_proxy_->BelongsToCurrentThread());
+}
+
+void CastSessionDelegateBase::StartUDP(
+ const net::IPEndPoint& local_endpoint,
+ const net::IPEndPoint& remote_endpoint,
+ scoped_ptr<base::DictionaryValue> options) {
+ DCHECK(io_message_loop_proxy_->BelongsToCurrentThread());
+
+ // CastSender uses the renderer's IO thread as the main thread. This reduces
+ // thread hopping for incoming video frames and outgoing network packets.
+ // TODO(hubbe): Create cast environment in ctor instead.
+ cast_environment_ = new CastEnvironment(
+ scoped_ptr<base::TickClock>(new base::DefaultTickClock()).Pass(),
+ base::MessageLoopProxy::current(),
+ g_cast_threads.Get().GetAudioEncodeMessageLoopProxy(),
+ g_cast_threads.Get().GetVideoEncodeMessageLoopProxy());
+
+ // Rationale for using unretained: The callback cannot be called after the
+ // destruction of CastTransportSenderIPC, and they both share the same thread.
+ cast_transport_.reset(new CastTransportSenderIPC(
+ local_endpoint,
+ remote_endpoint,
+ options.Pass(),
+ base::Bind(&CastSessionDelegateBase::ReceivePacket,
+ base::Unretained(this)),
+ base::Bind(&CastSessionDelegateBase::StatusNotificationCB,
+ base::Unretained(this)),
+ base::Bind(&CastSessionDelegateBase::LogRawEvents,
+ base::Unretained(this))));
+}
+
+void CastSessionDelegateBase::StatusNotificationCB(
+ media::cast::CastTransportStatus unused_status) {
+ DCHECK(io_message_loop_proxy_->BelongsToCurrentThread());
+ // TODO(hubbe): Call javascript UDPTransport error function.
+}
+
+CastSessionDelegate::CastSessionDelegate()
+ : weak_factory_(this) {
+ DCHECK(io_message_loop_proxy_.get());
+}
+
CastSessionDelegate::~CastSessionDelegate() {
DCHECK(io_message_loop_proxy_->BelongsToCurrentThread());
}
@@ -84,32 +128,18 @@ void CastSessionDelegate::StartVideo(
create_video_encode_mem_cb);
}
-void CastSessionDelegate::StartUDP(const net::IPEndPoint& remote_endpoint,
- scoped_ptr<base::DictionaryValue> options) {
- DCHECK(io_message_loop_proxy_->BelongsToCurrentThread());
-
- // CastSender uses the renderer's IO thread as the main thread. This reduces
- // thread hopping for incoming video frames and outgoing network packets.
- cast_environment_ = new CastEnvironment(
- scoped_ptr<base::TickClock>(new base::DefaultTickClock()).Pass(),
- base::MessageLoopProxy::current(),
- g_cast_threads.Get().GetAudioEncodeMessageLoopProxy(),
- g_cast_threads.Get().GetVideoEncodeMessageLoopProxy());
+void CastSessionDelegate::StartUDP(
+ const net::IPEndPoint& local_endpoint,
+ const net::IPEndPoint& remote_endpoint,
+ scoped_ptr<base::DictionaryValue> options) {
+ DCHECK(io_message_loop_proxy_->BelongsToCurrentThread());
+ CastSessionDelegateBase::StartUDP(local_endpoint,
+ remote_endpoint,
+ options.Pass());
event_subscribers_.reset(
new media::cast::RawEventSubscriberBundle(cast_environment_));
- // Rationale for using unretained: The callback cannot be called after the
- // destruction of CastTransportSenderIPC, and they both share the same thread.
- cast_transport_.reset(new CastTransportSenderIPC(
- net::IPEndPoint(),
- remote_endpoint,
- options.Pass(),
- media::cast::PacketReceiverCallback(),
- base::Bind(&CastSessionDelegate::StatusNotificationCB,
- base::Unretained(this)),
- base::Bind(&CastSessionDelegate::LogRawEvents, base::Unretained(this))));
-
cast_sender_ = CastSender::Create(cast_environment_, cast_transport_.get());
}
@@ -202,12 +232,6 @@ void CastSessionDelegate::GetStatsAndReset(bool is_audio,
callback.Run(stats.Pass());
}
-void CastSessionDelegate::StatusNotificationCB(
- media::cast::CastTransportStatus unused_status) {
- DCHECK(io_message_loop_proxy_->BelongsToCurrentThread());
- // TODO(hubbe): Call javascript UDPTransport error function.
-}
-
void CastSessionDelegate::OnOperationalStatusChange(
bool is_for_audio,
const ErrorCallback& error_callback,
@@ -257,6 +281,11 @@ void CastSessionDelegate::OnOperationalStatusChange(
}
}
+void CastSessionDelegate::ReceivePacket(
+ scoped_ptr<media::cast::Packet> packet) {
+ // Do nothing (frees packet)
+}
+
void CastSessionDelegate::LogRawEvents(
const std::vector<media::cast::PacketEvent>& packet_events,
const std::vector<media::cast::FrameEvent>& frame_events) {
« no previous file with comments | « chrome/renderer/media/cast_session_delegate.h ('k') | content/browser/media/capture/content_video_capture_device_core.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698