OLD | NEW |
---|---|
(Empty) | |
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 | |
3 // found in the LICENSE file. | |
4 | |
5 #ifndef MEDIA_FORMATS_MP2T_ES_ADAPTER_VIDEO_H_ | |
6 #define MEDIA_FORMATS_MP2T_ES_ADAPTER_VIDEO_H_ | |
7 | |
8 #include <deque> | |
9 #include <list> | |
10 | |
11 #include "base/callback.h" | |
12 #include "base/memory/ref_counted.h" | |
13 #include "base/time/time.h" | |
14 | |
15 namespace media { | |
16 class StreamParserBuffer; | |
17 class VideoDecoderConfig; | |
18 | |
19 namespace mp2t { | |
20 | |
21 // Some constraints of the MSE spec are not necessarily met by video streams | |
22 // inside an Mpeg2 TS stream. | |
23 // The goal of the ES adapter is to modify the incoming buffers to meet these | |
24 // constraints, e.g. | |
25 // - get the frame duration, | |
26 // - 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.
| |
27 class EsAdapterVideo { | |
28 public: | |
29 typedef base::Callback<void(const VideoDecoderConfig&)> NewVideoConfigCB; | |
30 typedef base::Callback<void(scoped_refptr<StreamParserBuffer>)> EmitBufferCB; | |
31 | |
32 EsAdapterVideo( | |
33 const NewVideoConfigCB& new_video_config_cb, | |
34 const EmitBufferCB& emit_buffer_cb); | |
35 ~EsAdapterVideo(); | |
36 | |
37 // Force the emission of the pending video buffers. | |
38 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
| |
39 | |
40 // Provide the configuration that applies to the upcoming video buffers. | |
41 void OnConfigChanged(const VideoDecoderConfig& video_decoder_config); | |
42 | |
43 // Provide a new video buffer. | |
44 void OnNewBuffer( | |
45 const scoped_refptr<StreamParserBuffer>& stream_parser_buffer); | |
46 | |
47 private: | |
48 typedef std::deque<scoped_refptr<StreamParserBuffer> > BufferQueue; | |
49 typedef std::pair<int64, VideoDecoderConfig> ConfigEntry; | |
50 | |
51 void ProcessPendingBuffers(bool flush); | |
52 | |
53 // Return the PTS of the frame that comes just after |current_pts| in | |
54 // presentation order. Return kNoTimestamp() if not found. | |
55 base::TimeDelta GetNextFramePts(base::TimeDelta current_pts); | |
56 | |
57 void ReplaceDiscardedFrames( | |
58 const scoped_refptr<StreamParserBuffer>& stream_parser_buffer); | |
59 | |
60 NewVideoConfigCB new_video_config_cb_; | |
61 EmitBufferCB emit_buffer_cb_; | |
62 | |
63 bool has_valid_config_; | |
64 bool has_valid_frame_; | |
65 | |
66 // Duration of the last video frame. | |
67 base::TimeDelta last_frame_duration_; | |
68 | |
69 // Association between a video config and a buffer index. | |
70 std::list<ConfigEntry> config_list_; | |
71 | |
72 // 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
| |
73 int64 buffer_index_; | |
74 | |
75 // List of buffer to be emitted and PTS of frames already emitted. | |
76 BufferQueue buffer_list_; | |
77 std::list<base::TimeDelta> emitted_pts_; | |
78 | |
79 // - Minimum PTS of discarded frames. | |
80 // - DTS of discarded frames. | |
81 base::TimeDelta discarded_frames_min_pts_; | |
82 std::list<base::TimeDelta> discarded_frames_dts_; | |
83 | |
84 DISALLOW_COPY_AND_ASSIGN(EsAdapterVideo); | |
85 }; | |
86 | |
87 } // namespace mp2t | |
88 } // namespace media | |
89 | |
90 #endif // MEDIA_FORMATS_MP2T_ES_ADAPTER_VIDEO_H_ | |
OLD | NEW |