| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "media/cast/net/rtp/rtp_sender.h" | 5 #include "media/cast/net/rtp/rtp_sender.h" |
| 6 | 6 |
| 7 #include "base/big_endian.h" | 7 #include "base/big_endian.h" |
| 8 #include "base/logging.h" | 8 #include "base/logging.h" |
| 9 #include "base/rand_util.h" | 9 #include "base/rand_util.h" |
| 10 #include "media/cast/constants.h" | 10 #include "media/cast/constants.h" |
| (...skipping 21 matching lines...) Expand all Loading... |
| 32 transport_task_runner_(transport_task_runner), | 32 transport_task_runner_(transport_task_runner), |
| 33 weak_factory_(this) { | 33 weak_factory_(this) { |
| 34 // Randomly set sequence number start value. | 34 // Randomly set sequence number start value. |
| 35 config_.sequence_number = base::RandInt(0, 65535); | 35 config_.sequence_number = base::RandInt(0, 65535); |
| 36 } | 36 } |
| 37 | 37 |
| 38 RtpSender::~RtpSender() {} | 38 RtpSender::~RtpSender() {} |
| 39 | 39 |
| 40 bool RtpSender::Initialize(const CastTransportRtpConfig& config) { | 40 bool RtpSender::Initialize(const CastTransportRtpConfig& config) { |
| 41 config_.ssrc = config.ssrc; | 41 config_.ssrc = config.ssrc; |
| 42 config_.payload_type = static_cast<int>(config.rtp_payload_type); | 42 // TODO(xjz): Android TV receivers expect the |payload_type| to be one of |
| 43 // these two specific values. This constraint needs to be removed and the |
| 44 // value of the |payload_type| can vary according to the spec: |
| 45 // https://tools.ietf.org/html/rfc3551. |
| 46 if (config.rtp_payload_type <= RtpPayloadType::AUDIO_LAST) |
| 47 config_.payload_type = 127; |
| 48 else |
| 49 config_.payload_type = 96; |
| 43 packetizer_.reset(new RtpPacketizer(transport_, &storage_, config_)); | 50 packetizer_.reset(new RtpPacketizer(transport_, &storage_, config_)); |
| 44 return true; | 51 return true; |
| 45 } | 52 } |
| 46 | 53 |
| 47 void RtpSender::SendFrame(const EncodedFrame& frame) { | 54 void RtpSender::SendFrame(const EncodedFrame& frame) { |
| 48 DCHECK(packetizer_); | 55 DCHECK(packetizer_); |
| 49 packetizer_->SendFrameAsPackets(frame); | 56 packetizer_->SendFrameAsPackets(frame); |
| 50 LOG_IF(DFATAL, storage_.GetNumberOfStoredFrames() > kMaxUnackedFrames) | 57 LOG_IF(DFATAL, storage_.GetNumberOfStoredFrames() > kMaxUnackedFrames) |
| 51 << "Possible bug: Frames are not being actively released from storage."; | 58 << "Possible bug: Frames are not being actively released from storage."; |
| 52 } | 59 } |
| (...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 152 int64_t RtpSender::GetLastByteSentForFrame(FrameId frame_id) { | 159 int64_t RtpSender::GetLastByteSentForFrame(FrameId frame_id) { |
| 153 const SendPacketVector* stored_packets = storage_.GetFramePackets(frame_id); | 160 const SendPacketVector* stored_packets = storage_.GetFramePackets(frame_id); |
| 154 if (!stored_packets) | 161 if (!stored_packets) |
| 155 return 0; | 162 return 0; |
| 156 PacketKey last_packet_key = stored_packets->rbegin()->first; | 163 PacketKey last_packet_key = stored_packets->rbegin()->first; |
| 157 return transport_->GetLastByteSentForPacket(last_packet_key); | 164 return transport_->GetLastByteSentForPacket(last_packet_key); |
| 158 } | 165 } |
| 159 | 166 |
| 160 } // namespace cast | 167 } // namespace cast |
| 161 } // namespace media | 168 } // namespace media |
| OLD | NEW |