| 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 #ifndef MEDIA_FILTERS_FRAME_PROCESSOR_H_ | 5 #ifndef MEDIA_FILTERS_FRAME_PROCESSOR_H_ |
| 6 #define MEDIA_FILTERS_FRAME_PROCESSOR_H_ | 6 #define MEDIA_FILTERS_FRAME_PROCESSOR_H_ |
| 7 | 7 |
| 8 #include <map> | 8 #include <map> |
| 9 #include <memory> |
| 9 | 10 |
| 10 #include "base/callback_forward.h" | 11 #include "base/callback_forward.h" |
| 11 #include "base/macros.h" | 12 #include "base/macros.h" |
| 12 #include "base/time/time.h" | 13 #include "base/time/time.h" |
| 13 #include "media/base/media_export.h" | 14 #include "media/base/media_export.h" |
| 14 #include "media/base/media_log.h" | 15 #include "media/base/media_log.h" |
| 15 #include "media/base/stream_parser.h" | 16 #include "media/base/stream_parser.h" |
| 16 #include "media/filters/chunk_demuxer.h" | 17 #include "media/filters/chunk_demuxer.h" |
| 17 | 18 |
| 18 namespace media { | 19 namespace media { |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 73 void Reset(); | 74 void Reset(); |
| 74 | 75 |
| 75 // Must be called when the audio config is updated. Used to manage when | 76 // Must be called when the audio config is updated. Used to manage when |
| 76 // the preroll buffer is cleared and the allowed "fudge" factor between | 77 // the preroll buffer is cleared and the allowed "fudge" factor between |
| 77 // preroll buffers. | 78 // preroll buffers. |
| 78 void OnPossibleAudioConfigUpdate(const AudioDecoderConfig& config); | 79 void OnPossibleAudioConfigUpdate(const AudioDecoderConfig& config); |
| 79 | 80 |
| 80 private: | 81 private: |
| 81 friend class FrameProcessorTest; | 82 friend class FrameProcessorTest; |
| 82 | 83 |
| 83 typedef std::map<StreamParser::TrackId, MseTrackBuffer*> TrackBufferMap; | |
| 84 | |
| 85 // If |track_buffers_| contains |id|, returns a pointer to the associated | 84 // If |track_buffers_| contains |id|, returns a pointer to the associated |
| 86 // MseTrackBuffer. Otherwise, returns NULL. | 85 // MseTrackBuffer. Otherwise, returns NULL. |
| 87 MseTrackBuffer* FindTrack(StreamParser::TrackId id); | 86 MseTrackBuffer* FindTrack(StreamParser::TrackId id); |
| 88 | 87 |
| 89 // Signals all track buffers' streams that a coded frame group is starting | 88 // Signals all track buffers' streams that a coded frame group is starting |
| 90 // with decode timestamp |start_timestamp|. | 89 // with decode timestamp |start_timestamp|. |
| 91 void NotifyStartOfCodedFrameGroup(DecodeTimestamp start_timestamp); | 90 void NotifyStartOfCodedFrameGroup(DecodeTimestamp start_timestamp); |
| 92 | 91 |
| 93 // Helper that signals each track buffer to append any processed, but not yet | 92 // Helper that signals each track buffer to append any processed, but not yet |
| 94 // appended, frames to its stream. Returns true on success, or false if one or | 93 // appended, frames to its stream. Returns true on success, or false if one or |
| (...skipping 22 matching lines...) Expand all Loading... |
| 117 const scoped_refptr<StreamParserBuffer>& buffer); | 116 const scoped_refptr<StreamParserBuffer>& buffer); |
| 118 | 117 |
| 119 // Helper that processes one frame with the coded frame processing algorithm. | 118 // Helper that processes one frame with the coded frame processing algorithm. |
| 120 // Returns false on error or true on success. | 119 // Returns false on error or true on success. |
| 121 bool ProcessFrame(const scoped_refptr<StreamParserBuffer>& frame, | 120 bool ProcessFrame(const scoped_refptr<StreamParserBuffer>& frame, |
| 122 base::TimeDelta append_window_start, | 121 base::TimeDelta append_window_start, |
| 123 base::TimeDelta append_window_end, | 122 base::TimeDelta append_window_end, |
| 124 base::TimeDelta* timestamp_offset); | 123 base::TimeDelta* timestamp_offset); |
| 125 | 124 |
| 126 // TrackId-indexed map of each track's stream. | 125 // TrackId-indexed map of each track's stream. |
| 127 TrackBufferMap track_buffers_; | 126 std::map<StreamParser::TrackId, std::unique_ptr<MseTrackBuffer>> |
| 127 track_buffers_; |
| 128 | 128 |
| 129 // The last audio buffer seen by the frame processor that was removed because | 129 // The last audio buffer seen by the frame processor that was removed because |
| 130 // it was entirely before the start of the append window. | 130 // it was entirely before the start of the append window. |
| 131 scoped_refptr<StreamParserBuffer> audio_preroll_buffer_; | 131 scoped_refptr<StreamParserBuffer> audio_preroll_buffer_; |
| 132 | 132 |
| 133 // The AudioDecoderConfig associated with buffers handed to ProcessFrames(). | 133 // The AudioDecoderConfig associated with buffers handed to ProcessFrames(). |
| 134 AudioDecoderConfig current_audio_config_; | 134 AudioDecoderConfig current_audio_config_; |
| 135 base::TimeDelta sample_duration_; | 135 base::TimeDelta sample_duration_; |
| 136 | 136 |
| 137 // The AppendMode of the associated SourceBuffer. | 137 // The AppendMode of the associated SourceBuffer. |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 171 // Counters that limit spam to |media_log_| for frame processor warnings. | 171 // Counters that limit spam to |media_log_| for frame processor warnings. |
| 172 int num_dropped_preroll_warnings_ = 0; | 172 int num_dropped_preroll_warnings_ = 0; |
| 173 int num_dts_beyond_pts_warnings_ = 0; | 173 int num_dts_beyond_pts_warnings_ = 0; |
| 174 | 174 |
| 175 DISALLOW_COPY_AND_ASSIGN(FrameProcessor); | 175 DISALLOW_COPY_AND_ASSIGN(FrameProcessor); |
| 176 }; | 176 }; |
| 177 | 177 |
| 178 } // namespace media | 178 } // namespace media |
| 179 | 179 |
| 180 #endif // MEDIA_FILTERS_FRAME_PROCESSOR_H_ | 180 #endif // MEDIA_FILTERS_FRAME_PROCESSOR_H_ |
| OLD | NEW |