Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(70)

Side by Side Diff: media/filters/chunk_demuxer.cc

Issue 149153002: MSE: Add StreamParser buffer remuxing utility and tests (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Address comments from PS4 Created 6 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « media/base/stream_parser_unittest.cc ('k') | media/filters/source_buffer_stream.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/filters/chunk_demuxer.h" 5 #include "media/filters/chunk_demuxer.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <deque> 8 #include <deque>
9 #include <limits> 9 #include <limits>
10 #include <list> 10 #include <list>
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after
183 // with the track numbers in |text_map|. 183 // with the track numbers in |text_map|.
184 // Returns true on a successful call. Returns false if an error occurred while 184 // Returns true on a successful call. Returns false if an error occurred while
185 // processing the buffers. 185 // processing the buffers.
186 bool OnNewBuffers(const StreamParser::BufferQueue& audio_buffers, 186 bool OnNewBuffers(const StreamParser::BufferQueue& audio_buffers,
187 const StreamParser::BufferQueue& video_buffers, 187 const StreamParser::BufferQueue& video_buffers,
188 const StreamParser::TextBufferQueueMap& text_map); 188 const StreamParser::TextBufferQueueMap& text_map);
189 189
190 // Helper function for OnNewBuffers() when new text buffers have been parsed. 190 // Helper function for OnNewBuffers() when new text buffers have been parsed.
191 // It applies |timestamp_offset_| to all buffers in |buffers| and then appends 191 // It applies |timestamp_offset_| to all buffers in |buffers| and then appends
192 // the (modified) buffers to the demuxer stream associated with 192 // the (modified) buffers to the demuxer stream associated with
193 // the track having |text_track_number|. 193 // the track having |text_track_id|.
194 // Returns true on a successful call. Returns false if an error occurred while 194 // Returns true on a successful call. Returns false if an error occurred while
195 // processing the buffers. 195 // processing the buffers.
196 bool OnTextBuffers(int text_track_number, 196 bool OnTextBuffers(StreamParser::TrackId text_track_id,
197 const StreamParser::BufferQueue& buffers); 197 const StreamParser::BufferQueue& buffers);
198 198
199 // Helper function that appends |buffers| to |stream| and calls 199 // Helper function that appends |buffers| to |stream| and calls
200 // |increase_duration_cb_| to potentially update the duration. 200 // |increase_duration_cb_| to potentially update the duration.
201 // Returns true if the append was successful. Returns false if 201 // Returns true if the append was successful. Returns false if
202 // |stream| is NULL or something in |buffers| caused the append to fail. 202 // |stream| is NULL or something in |buffers| caused the append to fail.
203 bool AppendAndUpdateDuration(ChunkDemuxerStream* stream, 203 bool AppendAndUpdateDuration(ChunkDemuxerStream* stream,
204 const StreamParser::BufferQueue& buffers); 204 const StreamParser::BufferQueue& buffers);
205 205
206 // Helper function that adds |timestamp_offset_| to each buffer in |buffers|. 206 // Helper function that adds |timestamp_offset_| to each buffer in |buffers|.
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
248 248
249 // The object used to parse appended data. 249 // The object used to parse appended data.
250 scoped_ptr<StreamParser> stream_parser_; 250 scoped_ptr<StreamParser> stream_parser_;
251 251
252 ChunkDemuxerStream* audio_; 252 ChunkDemuxerStream* audio_;
253 bool audio_needs_keyframe_; 253 bool audio_needs_keyframe_;
254 254
255 ChunkDemuxerStream* video_; 255 ChunkDemuxerStream* video_;
256 bool video_needs_keyframe_; 256 bool video_needs_keyframe_;
257 257
258 typedef std::map<int, ChunkDemuxerStream*> TextStreamMap; 258 typedef std::map<StreamParser::TrackId, ChunkDemuxerStream*> TextStreamMap;
259 TextStreamMap text_stream_map_; 259 TextStreamMap text_stream_map_;
260 260
261 LogCB log_cb_; 261 LogCB log_cb_;
262 262
263 DISALLOW_COPY_AND_ASSIGN(SourceState); 263 DISALLOW_COPY_AND_ASSIGN(SourceState);
264 }; 264 };
265 265
266 class ChunkDemuxerStream : public DemuxerStream { 266 class ChunkDemuxerStream : public DemuxerStream {
267 public: 267 public:
268 typedef std::deque<scoped_refptr<StreamParserBuffer> > BufferQueue; 268 typedef std::deque<scoped_refptr<StreamParserBuffer> > BufferQueue;
(...skipping 497 matching lines...) Expand 10 before | Expand all | Expand 10 after
766 new_media_segment_ = false; 766 new_media_segment_ = false;
767 } 767 }
768 768
769 bool SourceState::OnNewBuffers( 769 bool SourceState::OnNewBuffers(
770 const StreamParser::BufferQueue& audio_buffers, 770 const StreamParser::BufferQueue& audio_buffers,
771 const StreamParser::BufferQueue& video_buffers, 771 const StreamParser::BufferQueue& video_buffers,
772 const StreamParser::TextBufferQueueMap& text_map) { 772 const StreamParser::TextBufferQueueMap& text_map) {
773 DCHECK(!audio_buffers.empty() || !video_buffers.empty() || 773 DCHECK(!audio_buffers.empty() || !video_buffers.empty() ||
774 !text_map.empty()); 774 !text_map.empty());
775 775
776 // TODO(wolenetz): DCHECK + return false if any of these buffers have UNKNOWN
777 // type() in upcoming coded frame processing compliant implementation. See
778 // http://crbug.com/249422.
779
776 AdjustBufferTimestamps(audio_buffers); 780 AdjustBufferTimestamps(audio_buffers);
777 AdjustBufferTimestamps(video_buffers); 781 AdjustBufferTimestamps(video_buffers);
778 782
779 StreamParser::BufferQueue filtered_audio; 783 StreamParser::BufferQueue filtered_audio;
780 StreamParser::BufferQueue filtered_video; 784 StreamParser::BufferQueue filtered_video;
781 785
782 FilterWithAppendWindow(audio_buffers, &audio_needs_keyframe_, 786 FilterWithAppendWindow(audio_buffers, &audio_needs_keyframe_,
783 &filtered_audio); 787 &filtered_audio);
784 788
785 FilterWithAppendWindow(video_buffers, &video_needs_keyframe_, 789 FilterWithAppendWindow(video_buffers, &video_needs_keyframe_,
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
838 if (!OnTextBuffers(itr->first, text_buffers)) 842 if (!OnTextBuffers(itr->first, text_buffers))
839 return false; 843 return false;
840 } 844 }
841 } 845 }
842 846
843 DCHECK(!all_text_buffers_empty); 847 DCHECK(!all_text_buffers_empty);
844 return true; 848 return true;
845 } 849 }
846 850
847 bool SourceState::OnTextBuffers( 851 bool SourceState::OnTextBuffers(
848 int text_track_number, 852 StreamParser::TrackId text_track_id,
849 const StreamParser::BufferQueue& buffers) { 853 const StreamParser::BufferQueue& buffers) {
850 DCHECK(!buffers.empty()); 854 DCHECK(!buffers.empty());
851 855
852 TextStreamMap::iterator itr = text_stream_map_.find(text_track_number); 856 TextStreamMap::iterator itr = text_stream_map_.find(text_track_id);
853 if (itr == text_stream_map_.end()) 857 if (itr == text_stream_map_.end())
854 return false; 858 return false;
855 859
856 AdjustBufferTimestamps(buffers); 860 AdjustBufferTimestamps(buffers);
857 861
858 StreamParser::BufferQueue filtered_buffers; 862 StreamParser::BufferQueue filtered_buffers;
859 bool needs_keyframe = false; 863 bool needs_keyframe = false;
860 FilterWithAppendWindow(buffers, &needs_keyframe, &filtered_buffers); 864 FilterWithAppendWindow(buffers, &needs_keyframe, &filtered_buffers);
861 865
862 if (filtered_buffers.empty()) 866 if (filtered_buffers.empty())
(...skipping 998 matching lines...) Expand 10 before | Expand all | Expand 10 after
1861 } 1865 }
1862 1866
1863 void ChunkDemuxer::ShutdownAllStreams() { 1867 void ChunkDemuxer::ShutdownAllStreams() {
1864 for (SourceStateMap::iterator itr = source_state_map_.begin(); 1868 for (SourceStateMap::iterator itr = source_state_map_.begin();
1865 itr != source_state_map_.end(); ++itr) { 1869 itr != source_state_map_.end(); ++itr) {
1866 itr->second->Shutdown(); 1870 itr->second->Shutdown();
1867 } 1871 }
1868 } 1872 }
1869 1873
1870 } // namespace media 1874 } // namespace media
OLDNEW
« no previous file with comments | « media/base/stream_parser_unittest.cc ('k') | media/filters/source_buffer_stream.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698