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/formats/webm/webm_cluster_parser.h" | 5 #include "media/formats/webm/webm_cluster_parser.h" |
6 | 6 |
7 #include <memory> | 7 #include <memory> |
8 #include <utility> | 8 #include <utility> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
111 // call. | 111 // call. |
112 parser_.Reset(); | 112 parser_.Reset(); |
113 | 113 |
114 last_block_timecode_ = -1; | 114 last_block_timecode_ = -1; |
115 cluster_timecode_ = -1; | 115 cluster_timecode_ = -1; |
116 } | 116 } |
117 | 117 |
118 return result; | 118 return result; |
119 } | 119 } |
120 | 120 |
121 const WebMClusterParser::BufferQueue& WebMClusterParser::GetAudioBuffers() { | |
122 if (ready_buffer_upper_bound_ == kNoDecodeTimestamp()) | |
123 UpdateReadyBuffers(); | |
124 | |
125 return audio_.ready_buffers(); | |
126 } | |
127 | |
128 const WebMClusterParser::BufferQueue& WebMClusterParser::GetVideoBuffers() { | |
129 if (ready_buffer_upper_bound_ == kNoDecodeTimestamp()) | |
130 UpdateReadyBuffers(); | |
131 | |
132 return video_.ready_buffers(); | |
133 } | |
134 | |
135 const WebMClusterParser::TextBufferQueueMap& | 121 const WebMClusterParser::TextBufferQueueMap& |
136 WebMClusterParser::GetTextBuffers() { | 122 WebMClusterParser::GetTextBuffers() { |
137 if (ready_buffer_upper_bound_ == kNoDecodeTimestamp()) | 123 if (ready_buffer_upper_bound_ == kNoDecodeTimestamp()) |
138 UpdateReadyBuffers(); | 124 UpdateReadyBuffers(); |
139 | 125 |
140 // Translate our |text_track_map_| into |text_buffers_map_|, inserting rows in | 126 // Translate our |text_track_map_| into |text_buffers_map_|, inserting rows in |
141 // the output only for non-empty ready_buffer() queues in |text_track_map_|. | 127 // the output only for non-empty ready_buffer() queues in |text_track_map_|. |
142 text_buffers_map_.clear(); | 128 text_buffers_map_.clear(); |
143 for (TextTrackMap::const_iterator itr = text_track_map_.begin(); | 129 for (TextTrackMap::const_iterator itr = text_track_map_.begin(); |
144 itr != text_track_map_.end(); | 130 itr != text_track_map_.end(); |
145 ++itr) { | 131 ++itr) { |
146 const BufferQueue& text_buffers = itr->second.ready_buffers(); | 132 const BufferQueue& text_buffers = itr->second.ready_buffers(); |
147 if (!text_buffers.empty()) | 133 if (!text_buffers.empty()) |
148 text_buffers_map_.insert(std::make_pair(itr->first, text_buffers)); | 134 text_buffers_map_.insert(std::make_pair(itr->first, text_buffers)); |
149 } | 135 } |
150 | 136 |
151 return text_buffers_map_; | 137 return text_buffers_map_; |
152 } | 138 } |
153 | 139 |
140 void WebMClusterParser::GetBuffers(StreamParser::BufferQueueMap* buffers) { | |
141 DCHECK(buffers->empty()); | |
142 if (ready_buffer_upper_bound_ == kNoDecodeTimestamp()) | |
143 UpdateReadyBuffers(); | |
144 const BufferQueue& audio_buffers = audio_.ready_buffers(); | |
145 if (!audio_buffers.empty()) { | |
146 buffers->insert(std::make_pair(audio_.track_num(), audio_buffers)); | |
147 } | |
148 const BufferQueue& video_buffers = video_.ready_buffers(); | |
149 if (!video_buffers.empty()) { | |
150 buffers->insert(std::make_pair(video_.track_num(), video_buffers)); | |
151 } | |
152 const WebMClusterParser::TextBufferQueueMap& text_buffers = GetTextBuffers(); | |
153 for (const auto& it : text_buffers) { | |
154 if (!it.second.empty()) { | |
wolenetz
2016/08/23 21:31:21
per ::GetTextBuffers(), it.second is guaranteed to
servolk
2016/08/23 23:56:32
Done.
| |
155 buffers->insert(it); | |
156 } | |
157 } | |
158 } | |
159 | |
154 base::TimeDelta WebMClusterParser::TryGetEncodedAudioDuration( | 160 base::TimeDelta WebMClusterParser::TryGetEncodedAudioDuration( |
155 const uint8_t* data, | 161 const uint8_t* data, |
156 int size) { | 162 int size) { |
157 | 163 |
158 // Duration is currently read assuming the *entire* stream is unencrypted. | 164 // Duration is currently read assuming the *entire* stream is unencrypted. |
159 // The special "Signal Byte" prepended to Blocks in encrypted streams is | 165 // The special "Signal Byte" prepended to Blocks in encrypted streams is |
160 // assumed to not be present. | 166 // assumed to not be present. |
161 // TODO(chcunningham): Consider parsing "Signal Byte" for encrypted streams | 167 // TODO(chcunningham): Consider parsing "Signal Byte" for encrypted streams |
162 // to return duration for any unencrypted blocks. | 168 // to return duration for any unencrypted blocks. |
163 | 169 |
(...skipping 701 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
865 WebMClusterParser::FindTextTrack(int track_num) { | 871 WebMClusterParser::FindTextTrack(int track_num) { |
866 const TextTrackMap::iterator it = text_track_map_.find(track_num); | 872 const TextTrackMap::iterator it = text_track_map_.find(track_num); |
867 | 873 |
868 if (it == text_track_map_.end()) | 874 if (it == text_track_map_.end()) |
869 return NULL; | 875 return NULL; |
870 | 876 |
871 return &it->second; | 877 return &it->second; |
872 } | 878 } |
873 | 879 |
874 } // namespace media | 880 } // namespace media |
OLD | NEW |