| 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..0739fc3c276904757cab2dca1a6390fb63d84415
|
| --- /dev/null
|
| +++ b/media/formats/mp2t/es_adapter_video.h
|
| @@ -0,0 +1,98 @@
|
| +// 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 <utility>
|
| +
|
| +#include "base/callback.h"
|
| +#include "base/memory/ref_counted.h"
|
| +#include "base/time/time.h"
|
| +#include "media/base/media_export.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,
|
| +// - replace the leading non-key frames by the first key frame to avoid
|
| +// creating a hole in the video timeline.
|
| +class MEDIA_EXPORT 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();
|
| +
|
| + // Reset the ES adapter to its initial state.
|
| + void Reset();
|
| +
|
| + // 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);
|
| +
|
| + // Replace the leading non key frames by |stream_parser_buffer|
|
| + // (this one must be a key frame).
|
| + 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_;
|
| +
|
| + // Global index of the first buffer in |buffer_list_|.
|
| + 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_
|
|
|