Chromium Code Reviews| Index: media/formats/mp2t/es_adapter_video.h |
| diff --git a/media/formats/mp2t/es_adapter_video.h b/media/formats/mp2t/es_adapter_video.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..092cd531adcd27a3f2410ac404d5a5b5bb5dfffa |
| --- /dev/null |
| +++ b/media/formats/mp2t/es_adapter_video.h |
| @@ -0,0 +1,90 @@ |
| +// Copyright 2014 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#ifndef MEDIA_FORMATS_MP2T_ES_ADAPTER_VIDEO_H_ |
| +#define MEDIA_FORMATS_MP2T_ES_ADAPTER_VIDEO_H_ |
| + |
| +#include <deque> |
| +#include <list> |
| + |
| +#include "base/callback.h" |
| +#include "base/memory/ref_counted.h" |
| +#include "base/time/time.h" |
| + |
| +namespace media { |
| +class StreamParserBuffer; |
| +class VideoDecoderConfig; |
| + |
| +namespace mp2t { |
| + |
| +// Some constraints of the MSE spec are not necessarily met by video streams |
| +// inside an Mpeg2 TS stream. |
| +// The goal of the ES adapter is to modify the incoming buffers to meet these |
| +// constraints, e.g. |
| +// - get the frame duration, |
| +// - make sure the first video frame is a key frame. |
|
acolwell GONE FROM CHROMIUM
2014/07/09 20:01:10
This comment is a little misleading. The FrameProc
damienv1
2014/07/10 16:00:54
Right. The frame processor discards non key-frame.
|
| +class EsAdapterVideo { |
| + public: |
| + typedef base::Callback<void(const VideoDecoderConfig&)> NewVideoConfigCB; |
| + typedef base::Callback<void(scoped_refptr<StreamParserBuffer>)> EmitBufferCB; |
| + |
| + EsAdapterVideo( |
| + const NewVideoConfigCB& new_video_config_cb, |
| + const EmitBufferCB& emit_buffer_cb); |
| + ~EsAdapterVideo(); |
| + |
| + // Force the emission of the pending video buffers. |
| + void Flush(); |
|
acolwell GONE FROM CHROMIUM
2014/07/09 20:01:11
nit: s/Flush/EmitAllPendingBuffers/?
damienv1
2014/07/10 16:00:53
I am using Flush in EsParser.
I'll keep the same n
|
| + |
| + // Provide the configuration that applies to the upcoming video buffers. |
| + void OnConfigChanged(const VideoDecoderConfig& video_decoder_config); |
| + |
| + // Provide a new video buffer. |
| + void OnNewBuffer( |
| + const scoped_refptr<StreamParserBuffer>& stream_parser_buffer); |
| + |
| + private: |
| + typedef std::deque<scoped_refptr<StreamParserBuffer> > BufferQueue; |
| + typedef std::pair<int64, VideoDecoderConfig> ConfigEntry; |
| + |
| + void ProcessPendingBuffers(bool flush); |
| + |
| + // Return the PTS of the frame that comes just after |current_pts| in |
| + // presentation order. Return kNoTimestamp() if not found. |
| + base::TimeDelta GetNextFramePts(base::TimeDelta current_pts); |
| + |
| + void ReplaceDiscardedFrames( |
| + const scoped_refptr<StreamParserBuffer>& stream_parser_buffer); |
| + |
| + NewVideoConfigCB new_video_config_cb_; |
| + EmitBufferCB emit_buffer_cb_; |
| + |
| + bool has_valid_config_; |
| + bool has_valid_frame_; |
| + |
| + // Duration of the last video frame. |
| + base::TimeDelta last_frame_duration_; |
| + |
| + // Association between a video config and a buffer index. |
| + std::list<ConfigEntry> config_list_; |
| + |
| + // Index of the first buffer in |buffer_list_|. |
|
acolwell GONE FROM CHROMIUM
2014/07/09 20:01:10
nit: I think this comment may be missing something
damienv1
2014/07/10 16:00:53
Agree. The comment should be more accurate. This i
|
| + int64 buffer_index_; |
| + |
| + // List of buffer to be emitted and PTS of frames already emitted. |
| + BufferQueue buffer_list_; |
| + std::list<base::TimeDelta> emitted_pts_; |
| + |
| + // - Minimum PTS of discarded frames. |
| + // - DTS of discarded frames. |
| + base::TimeDelta discarded_frames_min_pts_; |
| + std::list<base::TimeDelta> discarded_frames_dts_; |
| + |
| + DISALLOW_COPY_AND_ASSIGN(EsAdapterVideo); |
| +}; |
| + |
| +} // namespace mp2t |
| +} // namespace media |
| + |
| +#endif // MEDIA_FORMATS_MP2T_ES_ADAPTER_VIDEO_H_ |