#include "chrome/renderer/media/cast_ipc_dispatcher.h"
#include "ipc/ipc_channel_proxy.h"
#include "media/cast/cast_sender.h"
-#include "media/cast/transport/cast_transport_sender.h"
+
+CastTransportSenderIPC::ClientCallbacks::ClientCallbacks() {}
+CastTransportSenderIPC::ClientCallbacks::~ClientCallbacks() {}
CastTransportSenderIPC::CastTransportSenderIPC(
- const media::cast::transport::CastTransportConfig& config,
- const media::cast::transport::CastTransportStatusCallback& status_cb)
- : status_callback_(status_cb) {
+ const net::IPEndPoint& remote_end_point,
+ scoped_ptr<base::DictionaryValue> options,
+ const media::cast::CastTransportStatusCallback& status_cb,
+ const media::cast::BulkRawEventsCallback& raw_events_cb)
+ : status_callback_(status_cb), raw_events_callback_(raw_events_cb) {
if (CastIPCDispatcher::Get()) {
channel_id_ = CastIPCDispatcher::Get()->AddSender(this);
}
- Send(new CastHostMsg_New(channel_id_, config));
+ Send(new CastHostMsg_New(channel_id_, remote_end_point, *options));
}
CastTransportSenderIPC::~CastTransportSenderIPC() {
}
}
-void CastTransportSenderIPC::SetPacketReceiver(
- const media::cast::transport::PacketReceiverCallback& packet_callback) {
- packet_callback_ = packet_callback;
+void CastTransportSenderIPC::InitializeAudio(
+ const media::cast::CastTransportRtpConfig& config,
+ const media::cast::RtcpCastMessageCallback& cast_message_cb,
+ const media::cast::RtcpRttCallback& rtt_cb) {
+ clients_[config.ssrc].cast_message_cb = cast_message_cb;
+ clients_[config.ssrc].rtt_cb = rtt_cb;
+ Send(new CastHostMsg_InitializeAudio(channel_id_, config));
}
-void CastTransportSenderIPC::InsertCodedAudioFrame(
- const media::cast::transport::EncodedAudioFrame* audio_frame,
- const base::TimeTicks& recorded_time) {
- Send(new CastHostMsg_InsertCodedAudioFrame(channel_id_,
- *audio_frame,
- recorded_time));
+void CastTransportSenderIPC::InitializeVideo(
+ const media::cast::CastTransportRtpConfig& config,
+ const media::cast::RtcpCastMessageCallback& cast_message_cb,
+ const media::cast::RtcpRttCallback& rtt_cb) {
+ clients_[config.ssrc].cast_message_cb = cast_message_cb;
+ clients_[config.ssrc].rtt_cb = rtt_cb;
+ Send(new CastHostMsg_InitializeVideo(channel_id_, config));
}
-void CastTransportSenderIPC::InsertCodedVideoFrame(
- const media::cast::transport::EncodedVideoFrame* video_frame,
- const base::TimeTicks& capture_time) {
- Send(new CastHostMsg_InsertCodedVideoFrame(channel_id_,
- *video_frame,
- capture_time));
+void CastTransportSenderIPC::InsertFrame(uint32 ssrc,
+ const media::cast::EncodedFrame& frame) {
+ Send(new CastHostMsg_InsertFrame(channel_id_, ssrc, frame));
}
-void CastTransportSenderIPC::SendRtcpFromRtpSender(
- uint32 packet_type_flags,
- const media::cast::transport::RtcpSenderInfo& sender_info,
- const media::cast::transport::RtcpDlrrReportBlock& dlrr,
- const media::cast::transport::RtcpSenderLogMessage& sender_log,
- uint32 sending_ssrc,
- const std::string& c_name) {
- struct media::cast::transport::SendRtcpFromRtpSenderData data;
- data.packet_type_flags = packet_type_flags;
- data.sending_ssrc = sending_ssrc;
- data.c_name = c_name;
- Send(new CastHostMsg_SendRtcpFromRtpSender(
- channel_id_,
- data,
- sender_info,
- dlrr,
- sender_log));
+void CastTransportSenderIPC::SendSenderReport(
+ uint32 ssrc,
+ base::TimeTicks current_time,
+ uint32 current_time_as_rtp_timestamp) {
+ Send(new CastHostMsg_SendSenderReport(channel_id_,
+ ssrc,
+ current_time,
+ current_time_as_rtp_timestamp));
}
-void CastTransportSenderIPC::ResendPackets(
- bool is_audio,
- const media::cast::MissingFramesAndPacketsMap& missing_packets) {
- Send(new CastHostMsg_ResendPackets(channel_id_,
- is_audio,
- missing_packets));
+void CastTransportSenderIPC::CancelSendingFrames(
+ uint32 ssrc, const std::vector<uint32>& frame_ids) {
+ Send(new CastHostMsg_CancelSendingFrames(channel_id_,
+ ssrc,
+ frame_ids));
}
-void CastTransportSenderIPC::SubscribeAudioRtpStatsCallback(
- const media::cast::transport::CastTransportRtpStatistics& callback) {
- audio_rtp_callback_ = callback;
+void CastTransportSenderIPC::ResendFrameForKickstart(
+ uint32 ssrc, uint32 frame_id) {
+ Send(new CastHostMsg_ResendFrameForKickstart(channel_id_,
+ ssrc,
+ frame_id));
}
-void CastTransportSenderIPC::SubscribeVideoRtpStatsCallback(
- const media::cast::transport::CastTransportRtpStatistics& callback) {
- video_rtp_callback_ = callback;
+void CastTransportSenderIPC::OnNotifyStatusChange(
+ media::cast::CastTransportStatus status) {
+ status_callback_.Run(status);
}
-
-void CastTransportSenderIPC::OnReceivedPacket(
- const media::cast::Packet& packet) {
- if (!packet_callback_.is_null()) {
- // TODO(hubbe): Perhaps an non-ownership-transferring cb here?
- scoped_ptr<media::cast::transport::Packet> packet_copy(
- new media::cast::transport::Packet(packet));
- packet_callback_.Run(packet_copy.Pass());
- } else {
- LOG(ERROR) << "CastIPCDispatcher::OnReceivedPacket "
- << "no packet callback yet.";
- }
+void CastTransportSenderIPC::OnRawEvents(
+ const std::vector<media::cast::PacketEvent>& packet_events,
+ const std::vector<media::cast::FrameEvent>& frame_events) {
+ raw_events_callback_.Run(packet_events, frame_events);
}
-void CastTransportSenderIPC::OnNotifyStatusChange(
- media::cast::transport::CastTransportStatus status) {
- status_callback_.Run(status);
+void CastTransportSenderIPC::OnRtt(uint32 ssrc, base::TimeDelta rtt) {
+ ClientMap::iterator it = clients_.find(ssrc);
+ if (it == clients_.end()) {
+ LOG(ERROR) << "Received RTT report from for unknown SSRC: " << ssrc;
+ return;
+ }
+ if (!it->second.rtt_cb.is_null())
+ it->second.rtt_cb.Run(rtt);
}
-void CastTransportSenderIPC::OnRtpStatistics(
- bool audio,
- const media::cast::transport::RtcpSenderInfo& sender_info,
- base::TimeTicks time_sent,
- uint32 rtp_timestamp) {
- const media::cast::transport::CastTransportRtpStatistics& callback =
- audio ? audio_rtp_callback_ : video_rtp_callback_;
- callback.Run(sender_info, time_sent, rtp_timestamp);
+void CastTransportSenderIPC::OnRtcpCastMessage(
+ uint32 ssrc,
+ const media::cast::RtcpCastMessage& cast_message) {
+ ClientMap::iterator it = clients_.find(ssrc);
+ if (it == clients_.end()) {
+ LOG(ERROR) << "Received cast message from for unknown SSRC: " << ssrc;
+ return;
+ }
+ if (it->second.cast_message_cb.is_null())
+ return;
+ it->second.cast_message_cb.Run(cast_message);
}
void CastTransportSenderIPC::Send(IPC::Message* message) {