Chromium Code Reviews| 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 "media/cast/rtp_sender/rtp_packetizer/rtp_packetizer.h" | 5 #include "media/cast/rtp_sender/rtp_packetizer/rtp_packetizer.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "media/cast/cast_defines.h" | 8 #include "media/cast/cast_defines.h" |
| 9 #include "media/cast/pacing/paced_sender.h" | 9 #include "media/cast/pacing/paced_sender.h" |
| 10 #include "net/base/big_endian.h" | 10 #include "net/base/big_endian.h" |
| (...skipping 21 matching lines...) Expand all Loading... | |
| 32 } | 32 } |
| 33 | 33 |
| 34 RtpPacketizer::~RtpPacketizer() {} | 34 RtpPacketizer::~RtpPacketizer() {} |
| 35 | 35 |
| 36 void RtpPacketizer::IncomingEncodedVideoFrame( | 36 void RtpPacketizer::IncomingEncodedVideoFrame( |
| 37 const EncodedVideoFrame* video_frame, | 37 const EncodedVideoFrame* video_frame, |
| 38 const base::TimeTicks& capture_time) { | 38 const base::TimeTicks& capture_time) { |
| 39 DCHECK(!config_.audio) << "Invalid state"; | 39 DCHECK(!config_.audio) << "Invalid state"; |
| 40 if (config_.audio) return; | 40 if (config_.audio) return; |
| 41 | 41 |
| 42 base::TimeTicks zero_time; | |
| 43 base::TimeDelta capture_delta = capture_time - zero_time; | |
| 44 | |
| 45 // Timestamp is in 90 KHz for video. | 42 // Timestamp is in 90 KHz for video. |
| 46 rtp_timestamp_ = static_cast<uint32>(capture_delta.InMilliseconds() * 90); | 43 rtp_timestamp_ = GetVideoRtpTimestamp(capture_time); |
| 47 time_last_sent_rtp_timestamp_ = capture_time; | 44 time_last_sent_rtp_timestamp_ = capture_time; |
| 48 | 45 |
| 49 Cast(video_frame->key_frame, | 46 Cast(video_frame->key_frame, |
| 50 video_frame->frame_id, | 47 video_frame->frame_id, |
| 51 video_frame->last_referenced_frame_id, | 48 video_frame->last_referenced_frame_id, |
| 52 rtp_timestamp_, | 49 rtp_timestamp_, |
| 53 video_frame->data); | 50 video_frame->data); |
| 54 } | 51 } |
| 55 | 52 |
| 56 void RtpPacketizer::IncomingEncodedAudioFrame( | 53 void RtpPacketizer::IncomingEncodedAudioFrame( |
| (...skipping 18 matching lines...) Expand all Loading... | |
| 75 | 72 |
| 76 *time_sent = time_last_sent_rtp_timestamp_; | 73 *time_sent = time_last_sent_rtp_timestamp_; |
| 77 *rtp_timestamp = rtp_timestamp_; | 74 *rtp_timestamp = rtp_timestamp_; |
| 78 return true; | 75 return true; |
| 79 } | 76 } |
| 80 | 77 |
| 81 void RtpPacketizer::Cast(bool is_key, | 78 void RtpPacketizer::Cast(bool is_key, |
| 82 uint8 frame_id, | 79 uint8 frame_id, |
| 83 uint8 reference_frame_id, | 80 uint8 reference_frame_id, |
| 84 uint32 timestamp, | 81 uint32 timestamp, |
| 85 std::vector<uint8> data) { | 82 std::vector<uint8> data) { |
|
Alpha Left Google
2013/11/14 19:54:57
I just noticed that this code does a copy of |data
| |
| 86 uint16 rtp_header_length = kCommonRtpHeaderLength + kCastRtpHeaderLength; | 83 uint16 rtp_header_length = kCommonRtpHeaderLength + kCastRtpHeaderLength; |
| 87 uint16 max_length = config_.max_payload_length - rtp_header_length - 1; | 84 uint16 max_length = config_.max_payload_length - rtp_header_length - 1; |
| 88 | 85 |
| 89 // Split the payload evenly (round number up). | 86 // Split the payload evenly (round number up). |
| 90 size_t num_packets = (data.size() + max_length) / max_length; | 87 size_t num_packets = (data.size() + max_length) / max_length; |
| 91 size_t payload_length = (data.size() + num_packets) / num_packets; | 88 size_t payload_length = (data.size() + num_packets) / num_packets; |
| 92 DCHECK_LE(payload_length, max_length) << "Invalid argument"; | 89 DCHECK_LE(payload_length, max_length) << "Invalid argument"; |
| 93 | 90 |
| 94 PacketList packets; | 91 PacketList packets; |
| 95 | 92 |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 146 packet->resize(start_size + 10); | 143 packet->resize(start_size + 10); |
| 147 net::BigEndianWriter big_endian_writer(&((*packet)[start_size]), 10); | 144 net::BigEndianWriter big_endian_writer(&((*packet)[start_size]), 10); |
| 148 big_endian_writer.WriteU16(sequence_number_); | 145 big_endian_writer.WriteU16(sequence_number_); |
| 149 big_endian_writer.WriteU32(time_stamp); | 146 big_endian_writer.WriteU32(time_stamp); |
| 150 big_endian_writer.WriteU32(config_.ssrc); | 147 big_endian_writer.WriteU32(config_.ssrc); |
| 151 ++sequence_number_; | 148 ++sequence_number_; |
| 152 } | 149 } |
| 153 | 150 |
| 154 } // namespace cast | 151 } // namespace cast |
| 155 } // namespace media | 152 } // namespace media |
| OLD | NEW |