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 22 matching lines...) Expand all Loading... |
33 } | 33 } |
34 | 34 |
35 RtpPacketizer::~RtpPacketizer() {} | 35 RtpPacketizer::~RtpPacketizer() {} |
36 | 36 |
37 void RtpPacketizer::IncomingEncodedVideoFrame( | 37 void RtpPacketizer::IncomingEncodedVideoFrame( |
38 const EncodedVideoFrame* video_frame, | 38 const EncodedVideoFrame* video_frame, |
39 const base::TimeTicks& capture_time) { | 39 const base::TimeTicks& capture_time) { |
40 DCHECK(!config_.audio) << "Invalid state"; | 40 DCHECK(!config_.audio) << "Invalid state"; |
41 if (config_.audio) return; | 41 if (config_.audio) return; |
42 | 42 |
43 base::TimeTicks zero_time; | |
44 base::TimeDelta capture_delta = capture_time - zero_time; | |
45 | |
46 // Timestamp is in 90 KHz for video. | 43 // Timestamp is in 90 KHz for video. |
47 rtp_timestamp_ = static_cast<uint32>(capture_delta.InMilliseconds() * 90); | 44 rtp_timestamp_ = GetVideoRtpTimestamp(capture_time); |
48 time_last_sent_rtp_timestamp_ = capture_time; | 45 time_last_sent_rtp_timestamp_ = capture_time; |
49 | 46 |
50 Cast(video_frame->key_frame, | 47 Cast(video_frame->key_frame, |
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( |
57 const EncodedAudioFrame* audio_frame, | 54 const EncodedAudioFrame* audio_frame, |
(...skipping 88 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 |