| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chrome/renderer/media/cast_session_delegate.h" | 5 #include "chrome/renderer/media/cast_session_delegate.h" |
| 6 | 6 |
| 7 #include "base/lazy_instance.h" | 7 #include "base/lazy_instance.h" |
| 8 #include "base/logging.h" | 8 #include "base/logging.h" |
| 9 #include "base/message_loop/message_loop_proxy.h" | 9 #include "base/message_loop/message_loop_proxy.h" |
| 10 #include "chrome/renderer/media/cast_threads.h" | 10 #include "chrome/renderer/media/cast_threads.h" |
| (...skipping 20 matching lines...) Expand all Loading... |
| 31 | 31 |
| 32 // Allow 9MB for serialized video / audio event logs. | 32 // Allow 9MB for serialized video / audio event logs. |
| 33 const int kMaxSerializedBytes = 9000000; | 33 const int kMaxSerializedBytes = 9000000; |
| 34 | 34 |
| 35 // Assume serialized log data for each frame will take up to 150 bytes. | 35 // Assume serialized log data for each frame will take up to 150 bytes. |
| 36 const int kMaxVideoEventEntries = kMaxSerializedBytes / 150; | 36 const int kMaxVideoEventEntries = kMaxSerializedBytes / 150; |
| 37 | 37 |
| 38 // Assume serialized log data for each frame will take up to 75 bytes. | 38 // Assume serialized log data for each frame will take up to 75 bytes. |
| 39 const int kMaxAudioEventEntries = kMaxSerializedBytes / 75; | 39 const int kMaxAudioEventEntries = kMaxSerializedBytes / 75; |
| 40 | 40 |
| 41 void CreateVideoEncodeAccelerator(const base::Callback< |
| 42 void(scoped_refptr<base::SingleThreadTaskRunner>, |
| 43 scoped_ptr<media::VideoEncodeAccelerator>)>& callback) { |
| 44 NOTIMPLEMENTED(); |
| 45 // Delegate the call to content API on the render thread. |
| 46 } |
| 47 |
| 48 void CreateVideoEncodeMemory( |
| 49 size_t size, |
| 50 const base::Callback<void(scoped_ptr<base::SharedMemory>)>&) { |
| 51 NOTIMPLEMENTED(); |
| 52 // Delegate the call to content API on the render thread. |
| 53 } |
| 54 |
| 41 } // namespace | 55 } // namespace |
| 42 | 56 |
| 43 CastSessionDelegate::CastSessionDelegate() | 57 CastSessionDelegate::CastSessionDelegate() |
| 44 : io_message_loop_proxy_( | 58 : io_message_loop_proxy_( |
| 45 content::RenderThread::Get()->GetIOMessageLoopProxy()), | 59 content::RenderThread::Get()->GetIOMessageLoopProxy()), |
| 46 weak_factory_(this) { | 60 weak_factory_(this) { |
| 47 DCHECK(io_message_loop_proxy_); | 61 DCHECK(io_message_loop_proxy_); |
| 48 } | 62 } |
| 49 | 63 |
| 50 CastSessionDelegate::~CastSessionDelegate() { | 64 CastSessionDelegate::~CastSessionDelegate() { |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 96 return; | 110 return; |
| 97 } | 111 } |
| 98 | 112 |
| 99 video_frame_input_available_callback_ = callback; | 113 video_frame_input_available_callback_ = callback; |
| 100 | 114 |
| 101 media::cast::transport::CastTransportVideoConfig transport_config; | 115 media::cast::transport::CastTransportVideoConfig transport_config; |
| 102 transport_config.base.ssrc = config.sender_ssrc; | 116 transport_config.base.ssrc = config.sender_ssrc; |
| 103 transport_config.codec = config.codec; | 117 transport_config.codec = config.codec; |
| 104 transport_config.base.rtp_config = config.rtp_config; | 118 transport_config.base.rtp_config = config.rtp_config; |
| 105 cast_transport_->InitializeVideo(transport_config); | 119 cast_transport_->InitializeVideo(transport_config); |
| 106 // TODO(mikhal): Pass in a valid GpuVideoAcceleratorFactories to support | |
| 107 // hardware video encoding. | |
| 108 cast_sender_->InitializeVideo( | 120 cast_sender_->InitializeVideo( |
| 109 config, | 121 config, |
| 110 base::Bind(&CastSessionDelegate::InitializationResultCB, | 122 base::Bind(&CastSessionDelegate::InitializationResultCB, |
| 111 weak_factory_.GetWeakPtr()), | 123 weak_factory_.GetWeakPtr()), |
| 112 NULL /* GPU*/); | 124 base::Bind(&CreateVideoEncodeAccelerator), |
| 125 base::Bind(&CreateVideoEncodeMemory)); |
| 113 } | 126 } |
| 114 | 127 |
| 115 void CastSessionDelegate::StartUDP(const net::IPEndPoint& remote_endpoint) { | 128 void CastSessionDelegate::StartUDP(const net::IPEndPoint& remote_endpoint) { |
| 116 DCHECK(io_message_loop_proxy_->BelongsToCurrentThread()); | 129 DCHECK(io_message_loop_proxy_->BelongsToCurrentThread()); |
| 117 | 130 |
| 118 // Logging: enable raw events and stats collection. | 131 // Logging: enable raw events and stats collection. |
| 119 media::cast::CastLoggingConfig logging_config = | 132 media::cast::CastLoggingConfig logging_config = |
| 120 media::cast::GetLoggingConfigWithRawEventsAndStatsEnabled(); | 133 media::cast::GetLoggingConfigWithRawEventsAndStatsEnabled(); |
| 121 | 134 |
| 122 // CastSender uses the renderer's IO thread as the main thread. This reduces | 135 // CastSender uses the renderer's IO thread as the main thread. This reduces |
| (...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 266 ++it) { | 279 ++it) { |
| 267 cast_environment_->Logging()->InsertPacketEvent(it->timestamp, | 280 cast_environment_->Logging()->InsertPacketEvent(it->timestamp, |
| 268 it->type, | 281 it->type, |
| 269 it->rtp_timestamp, | 282 it->rtp_timestamp, |
| 270 it->frame_id, | 283 it->frame_id, |
| 271 it->packet_id, | 284 it->packet_id, |
| 272 it->max_packet_id, | 285 it->max_packet_id, |
| 273 it->size); | 286 it->size); |
| 274 } | 287 } |
| 275 } | 288 } |
| OLD | NEW |