OLD | NEW |
1 // Copyright (c) 2015 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2015 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/formats/webm/opus_packet_builder.h" |
| 6 |
5 #include "base/logging.h" | 7 #include "base/logging.h" |
6 #include "media/formats/webm/opus_packet_builder.h" | 8 #include "base/memory/ptr_util.h" |
7 #include "media/formats/webm/webm_cluster_parser.h" | 9 #include "media/formats/webm/webm_cluster_parser.h" |
8 | 10 |
9 namespace media { | 11 namespace media { |
10 | 12 |
11 OpusPacket::OpusPacket(uint8_t config, uint8_t frame_count, bool is_VBR) { | 13 OpusPacket::OpusPacket(uint8_t config, uint8_t frame_count, bool is_VBR) { |
12 DCHECK_GE(config, 0); | 14 DCHECK_GE(config, 0); |
13 DCHECK_LT(config, kNumPossibleOpusConfigs); | 15 DCHECK_LT(config, kNumPossibleOpusConfigs); |
14 DCHECK_GE(frame_count, kMinOpusPacketFrameCount); | 16 DCHECK_GE(frame_count, kMinOpusPacketFrameCount); |
15 DCHECK_LE(frame_count, kMaxOpusPacketFrameCount); | 17 DCHECK_LE(frame_count, kMaxOpusPacketFrameCount); |
16 | 18 |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
55 } | 57 } |
56 | 58 |
57 int OpusPacket::size() const { | 59 int OpusPacket::size() const { |
58 return data_.size(); | 60 return data_.size(); |
59 } | 61 } |
60 | 62 |
61 double OpusPacket::duration_ms() const { | 63 double OpusPacket::duration_ms() const { |
62 return duration_ms_; | 64 return duration_ms_; |
63 } | 65 } |
64 | 66 |
65 ScopedVector<OpusPacket> BuildAllOpusPackets() { | 67 std::vector<std::unique_ptr<OpusPacket>> BuildAllOpusPackets() { |
66 ScopedVector<OpusPacket> opus_packets; | 68 std::vector<std::unique_ptr<OpusPacket>> opus_packets; |
67 | 69 |
68 for (int frame_count = kMinOpusPacketFrameCount; | 70 for (int frame_count = kMinOpusPacketFrameCount; |
69 frame_count <= kMaxOpusPacketFrameCount; frame_count++) { | 71 frame_count <= kMaxOpusPacketFrameCount; frame_count++) { |
70 for (int opus_config_num = 0; opus_config_num < kNumPossibleOpusConfigs; | 72 for (int opus_config_num = 0; opus_config_num < kNumPossibleOpusConfigs; |
71 opus_config_num++) { | 73 opus_config_num++) { |
72 bool is_VBR = false; | 74 bool is_VBR = false; |
73 opus_packets.push_back( | 75 opus_packets.push_back( |
74 new OpusPacket(opus_config_num, frame_count, is_VBR)); | 76 base::MakeUnique<OpusPacket>(opus_config_num, frame_count, is_VBR)); |
75 | 77 |
76 if (frame_count >= 2) { | 78 if (frame_count >= 2) { |
77 // Add another packet with VBR flag toggled. For frame counts >= 2, | 79 // Add another packet with VBR flag toggled. For frame counts >= 2, |
78 // VBR triggers changes to packet framing. | 80 // VBR triggers changes to packet framing. |
79 is_VBR = true; | 81 is_VBR = true; |
80 opus_packets.push_back( | 82 opus_packets.push_back( |
81 new OpusPacket(opus_config_num, frame_count, is_VBR)); | 83 base::MakeUnique<OpusPacket>(opus_config_num, frame_count, is_VBR)); |
82 } | 84 } |
83 } | 85 } |
84 } | 86 } |
85 | 87 |
86 return opus_packets; | 88 return opus_packets; |
87 } | 89 } |
88 | 90 |
89 } // namespace media | 91 } // namespace media |
OLD | NEW |