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/sender/vp8_encoder.h" | 5 #include "media/cast/sender/vp8_encoder.h" |
6 | 6 |
7 #include <vector> | 7 #include <vector> |
8 | 8 |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "media/base/video_frame.h" | 10 #include "media/base/video_frame.h" |
11 #include "media/cast/cast_defines.h" | 11 #include "media/cast/cast_defines.h" |
12 #include "media/cast/net/cast_transport_config.h" | 12 #include "media/cast/net/cast_transport_config.h" |
13 #include "third_party/libvpx/source/libvpx/vpx/vp8cx.h" | 13 #include "third_party/libvpx/source/libvpx/vpx/vp8cx.h" |
14 | 14 |
15 namespace media { | 15 namespace media { |
16 namespace cast { | 16 namespace cast { |
17 | 17 |
18 static const uint32 kMinIntra = 300; | 18 static const uint32 kMinIntra = 300; |
19 | 19 |
20 static int ComputeMaxNumOfRepeatedBuffes(int max_unacked_frames) { | 20 static int ComputeMaxNumOfRepeatedBuffers(int max_unacked_frames) { |
21 if (max_unacked_frames > kNumberOfVp8VideoBuffers) | 21 if (max_unacked_frames > kNumberOfVp8VideoBuffers) |
22 return (max_unacked_frames - 1) / kNumberOfVp8VideoBuffers; | 22 return (max_unacked_frames - 1) / kNumberOfVp8VideoBuffers; |
23 | 23 |
24 return 0; | 24 return 0; |
25 } | 25 } |
26 | 26 |
27 Vp8Encoder::Vp8Encoder(const VideoSenderConfig& video_config, | 27 Vp8Encoder::Vp8Encoder(const VideoSenderConfig& video_config, |
28 int max_unacked_frames) | 28 int max_unacked_frames) |
29 : cast_config_(video_config), | 29 : cast_config_(video_config), |
30 use_multiple_video_buffers_( | 30 use_multiple_video_buffers_( |
31 cast_config_.max_number_of_video_buffers_used == | 31 cast_config_.max_number_of_video_buffers_used == |
32 kNumberOfVp8VideoBuffers), | 32 kNumberOfVp8VideoBuffers), |
33 max_number_of_repeated_buffers_in_a_row_( | 33 max_number_of_repeated_buffers_in_a_row_( |
34 ComputeMaxNumOfRepeatedBuffes(max_unacked_frames)), | 34 ComputeMaxNumOfRepeatedBuffers(max_unacked_frames)), |
35 key_frame_requested_(true), | 35 key_frame_requested_(true), |
36 first_frame_received_(false), | 36 first_frame_received_(false), |
37 last_encoded_frame_id_(kStartFrameId), | 37 last_encoded_frame_id_(kStartFrameId), |
38 number_of_repeated_buffers_(0) { | 38 number_of_repeated_buffers_(0) { |
39 // TODO(pwestin): we need to figure out how to synchronize the acking with the | 39 // TODO(pwestin): we need to figure out how to synchronize the acking with the |
40 // internal state of the encoder, ideally the encoder will tell if we can | 40 // internal state of the encoder, ideally the encoder will tell if we can |
41 // send another frame. | 41 // send another frame. |
42 DCHECK(!use_multiple_video_buffers_ || | 42 DCHECK(!use_multiple_video_buffers_ || |
43 max_number_of_repeated_buffers_in_a_row_ == 0) | 43 max_number_of_repeated_buffers_in_a_row_ == 0) |
44 << "Invalid config"; | 44 << "Invalid config"; |
(...skipping 359 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
404 float scale_parameter = 0.5; | 404 float scale_parameter = 0.5; |
405 uint32 target_pct = optimal_buffer_size_ms * scale_parameter * | 405 uint32 target_pct = optimal_buffer_size_ms * scale_parameter * |
406 cast_config_.max_frame_rate / 10; | 406 cast_config_.max_frame_rate / 10; |
407 | 407 |
408 // Don't go below 3 times the per frame bandwidth. | 408 // Don't go below 3 times the per frame bandwidth. |
409 return std::max(target_pct, kMinIntra); | 409 return std::max(target_pct, kMinIntra); |
410 } | 410 } |
411 | 411 |
412 } // namespace cast | 412 } // namespace cast |
413 } // namespace media | 413 } // namespace media |
OLD | NEW |