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/video_sender/video_encoder.h" | 5 #include "media/cast/video_sender/video_encoder.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/logging.h" | 8 #include "base/logging.h" |
9 | 9 |
10 namespace media { | 10 namespace media { |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
58 const CodecDynamicConfig& dynamic_config, | 58 const CodecDynamicConfig& dynamic_config, |
59 const FrameEncodedCallback& frame_encoded_callback, | 59 const FrameEncodedCallback& frame_encoded_callback, |
60 const base::Closure frame_release_callback) { | 60 const base::Closure frame_release_callback) { |
61 if (dynamic_config.key_frame_requested) { | 61 if (dynamic_config.key_frame_requested) { |
62 vp8_encoder_->GenerateKeyFrame(); | 62 vp8_encoder_->GenerateKeyFrame(); |
63 } | 63 } |
64 vp8_encoder_->LatestFrameIdToReference( | 64 vp8_encoder_->LatestFrameIdToReference( |
65 dynamic_config.latest_frame_id_to_reference); | 65 dynamic_config.latest_frame_id_to_reference); |
66 vp8_encoder_->UpdateRates(dynamic_config.bit_rate); | 66 vp8_encoder_->UpdateRates(dynamic_config.bit_rate); |
67 | 67 |
68 | |
69 uint32 rtp_timestamp = GetVideoRtpTimestamp(capture_time); | |
70 cast_environment_->Logging()->InsertFrameEvent(kVideoFrameSentToEncoder, | |
71 -1, rtp_timestamp); | |
Alpha Left Google
2013/11/14 00:29:24
Add a TODO here to replace -1 with something meani
mikhal
2013/11/14 17:42:31
Replaced with const, as in other locations.
On 201
| |
68 scoped_ptr<EncodedVideoFrame> encoded_frame(new EncodedVideoFrame()); | 72 scoped_ptr<EncodedVideoFrame> encoded_frame(new EncodedVideoFrame()); |
69 bool retval = vp8_encoder_->Encode(*video_frame, encoded_frame.get()); | 73 bool retval = vp8_encoder_->Encode(*video_frame, encoded_frame.get()); |
70 | 74 |
71 // We are done with the video frame release it. | 75 // We are done with the video frame release it. |
72 cast_environment_->PostTask(CastEnvironment::MAIN, FROM_HERE, | 76 cast_environment_->PostTask(CastEnvironment::MAIN, FROM_HERE, |
73 frame_release_callback); | 77 frame_release_callback); |
74 | 78 |
75 if (!retval) { | 79 if (!retval) { |
76 VLOG(1) << "Encoding failed"; | 80 VLOG(1) << "Encoding failed"; |
77 return; | 81 return; |
78 } | 82 } |
79 if (encoded_frame->data.size() <= 0) { | 83 if (encoded_frame->data.size() <= 0) { |
80 VLOG(1) << "Encoding resulted in an empty frame"; | 84 VLOG(1) << "Encoding resulted in an empty frame"; |
81 return; | 85 return; |
82 } | 86 } |
87 cast_environment_->Logging()->InsertFrameEvent(kVideoFrameEncoded, | |
88 rtp_timestamp, -1); | |
Alpha Left Google
2013/11/14 00:29:24
Add a TODO here to replace -1 with something meani
mikhal
2013/11/14 17:42:31
see above
On 2013/11/14 00:29:24, Alpha wrote:
| |
83 cast_environment_->PostTask(CastEnvironment::MAIN, FROM_HERE, | 89 cast_environment_->PostTask(CastEnvironment::MAIN, FROM_HERE, |
84 base::Bind(frame_encoded_callback, | 90 base::Bind(frame_encoded_callback, |
85 base::Passed(&encoded_frame), capture_time)); | 91 base::Passed(&encoded_frame), capture_time)); |
86 } | 92 } |
87 | 93 |
88 // Inform the encoder about the new target bit rate. | 94 // Inform the encoder about the new target bit rate. |
89 void VideoEncoder::SetBitRate(int new_bit_rate) { | 95 void VideoEncoder::SetBitRate(int new_bit_rate) { |
90 dynamic_config_.bit_rate = new_bit_rate; | 96 dynamic_config_.bit_rate = new_bit_rate; |
91 } | 97 } |
92 | 98 |
(...skipping 11 matching lines...) Expand all Loading... | |
104 void VideoEncoder::LatestFrameIdToReference(uint8 frame_id) { | 110 void VideoEncoder::LatestFrameIdToReference(uint8 frame_id) { |
105 dynamic_config_.latest_frame_id_to_reference = frame_id; | 111 dynamic_config_.latest_frame_id_to_reference = frame_id; |
106 } | 112 } |
107 | 113 |
108 int VideoEncoder::NumberOfSkippedFrames() const { | 114 int VideoEncoder::NumberOfSkippedFrames() const { |
109 return skip_count_; | 115 return skip_count_; |
110 } | 116 } |
111 | 117 |
112 } // namespace cast | 118 } // namespace cast |
113 } // namespace media | 119 } // namespace media |
OLD | NEW |