OLD | NEW |
---|---|
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 #ifndef MEDIA_BASE_PIPELINE_H_ | 5 #ifndef MEDIA_BASE_PIPELINE_H_ |
6 #define MEDIA_BASE_PIPELINE_H_ | 6 #define MEDIA_BASE_PIPELINE_H_ |
7 | 7 |
8 #include <memory> | 8 #include <memory> |
9 | 9 |
10 #include "base/memory/ref_counted.h" | 10 #include "base/memory/ref_counted.h" |
11 #include "base/time/time.h" | 11 #include "base/time/time.h" |
12 #include "media/base/buffering_state.h" | 12 #include "media/base/buffering_state.h" |
13 #include "media/base/cdm_context.h" | 13 #include "media/base/cdm_context.h" |
14 #include "media/base/media_export.h" | 14 #include "media/base/media_export.h" |
15 #include "media/base/pipeline_metadata.h" | |
15 #include "media/base/pipeline_status.h" | 16 #include "media/base/pipeline_status.h" |
16 #include "media/base/ranges.h" | 17 #include "media/base/ranges.h" |
17 #include "media/base/text_track.h" | 18 #include "media/base/text_track.h" |
18 #include "media/base/video_rotation.h" | 19 #include "media/base/video_rotation.h" |
19 #include "ui/gfx/geometry/size.h" | 20 #include "ui/gfx/geometry/size.h" |
20 | 21 |
21 namespace media { | 22 namespace media { |
22 | 23 |
23 class Demuxer; | 24 class Demuxer; |
24 class Renderer; | 25 class Renderer; |
25 class VideoFrame; | 26 class VideoFrame; |
26 | 27 |
27 // Metadata describing a pipeline once it has been initialized. | |
28 struct PipelineMetadata { | |
29 PipelineMetadata() | |
30 : has_audio(false), has_video(false), video_rotation(VIDEO_ROTATION_0) {} | |
31 | |
32 bool has_audio; | |
33 bool has_video; | |
34 gfx::Size natural_size; | |
35 VideoRotation video_rotation; | |
36 base::Time timeline_offset; | |
37 }; | |
38 | |
39 typedef base::Callback<void(PipelineMetadata)> PipelineMetadataCB; | |
40 | |
41 class MEDIA_EXPORT Pipeline { | 28 class MEDIA_EXPORT Pipeline { |
42 public: | 29 public: |
43 // Used to paint VideoFrame. | 30 class Client { |
44 typedef base::Callback<void(const scoped_refptr<VideoFrame>&)> PaintCB; | 31 public: |
32 virtual ~Client() {} | |
sandersd (OOO until July 31)
2016/04/26 23:16:36
It seems to me that this class should be pure-virt
| |
33 | |
34 // Executed whenever an error occurs but hasn't been reported already | |
35 // through another callback. | |
36 virtual void OnError(PipelineStatus status) {} | |
37 | |
38 // Executed whenever the media reaches the end. | |
39 virtual void OnEnded() {} | |
40 | |
41 // Executed when the content duration, container video size, start time, | |
42 // and whether the content has audio and/or video in supported formats are | |
43 // known. | |
44 virtual void OnMetadata(PipelineMetadata metadata) {} | |
45 | |
46 // Executed whenever there are changes in the buffering state of the | |
47 // pipeline. | |
48 virtual void OnBufferingStateChange(BufferingState state) {} | |
49 | |
50 // Executed whenever the presentation duration changes. | |
51 virtual void OnDurationChange() {} | |
52 | |
53 // Executed whenever a text track is added. | |
54 virtual void OnAddTextTrack(const TextTrackConfig& config, | |
55 const AddTextTrackDoneCB& done_cb) {} | |
56 | |
57 // Executed whenever the key needed to decrypt the stream is not available. | |
58 virtual void OnWaitingForDecryptionKey() {} | |
59 }; | |
60 | |
61 virtual ~Pipeline() {} | |
45 | 62 |
46 // Build a pipeline to using the given |demuxer| and |renderer| to construct | 63 // Build a pipeline to using the given |demuxer| and |renderer| to construct |
47 // a filter chain, executing |seek_cb| when the initial seek has completed. | 64 // a filter chain, executing |seek_cb| when the initial seek has completed. |
48 // | 65 // |
49 // The following permanent callbacks will be executed as follows up until | 66 // The following permanent callbacks will be executed on PipelineClient up |
50 // Stop() has completed: | 67 // until Stop() has completed: |
51 // |ended_cb| will be executed whenever the media reaches the end. | 68 // OnError |
52 // |error_cb| will be executed whenever an error occurs but hasn't been | 69 // OnEnded |
53 // reported already through another callback. | 70 // OnMetadata |
54 // |metadata_cb| will be executed when the content duration, container video | 71 // OnBufferingStateChange |
55 // size, start time, and whether the content has audio and/or | 72 // OnDurationChange |
56 // video in supported formats are known. | 73 // OnAddTextTrack |
57 // |buffering_state_cb| will be executed whenever there are changes in the | 74 // OnWaitingForDecryptionKey |
58 // overall buffering state of the pipeline. | 75 // |
59 // |duration_change_cb| optional callback that will be executed whenever the | |
60 // presentation duration changes. | |
61 // |add_text_track_cb| will be executed whenever a text track is added. | |
62 // |waiting_for_decryption_key_cb| will be executed whenever the key needed | |
63 // to decrypt the stream is not available. | |
64 // It is an error to call this method after the pipeline has already started. | 76 // It is an error to call this method after the pipeline has already started. |
77 // TODO(xhwang): Rename |seek_cb| to |start_cb|. | |
65 virtual void Start(Demuxer* demuxer, | 78 virtual void Start(Demuxer* demuxer, |
66 std::unique_ptr<Renderer> renderer, | 79 std::unique_ptr<Renderer> renderer, |
67 const base::Closure& ended_cb, | 80 Client* client, |
68 const PipelineStatusCB& error_cb, | 81 const PipelineStatusCB& seek_cb) = 0; |
69 const PipelineStatusCB& seek_cb, | |
70 const PipelineMetadataCB& metadata_cb, | |
71 const BufferingStateCB& buffering_state_cb, | |
72 const base::Closure& duration_change_cb, | |
73 const AddTextTrackCB& add_text_track_cb, | |
74 const base::Closure& waiting_for_decryption_key_cb) = 0; | |
75 | 82 |
76 // Asynchronously stops the pipeline, executing |stop_cb| when the pipeline | 83 // Asynchronously stops the pipeline, executing |stop_cb| when the pipeline |
77 // teardown has completed. | 84 // teardown has completed. |
78 // | 85 // |
79 // Stop() must complete before destroying the pipeline. It it permissible to | 86 // Stop() must complete before destroying the pipeline. It it permissible to |
80 // call Stop() at any point during the lifetime of the pipeline. | 87 // call Stop() at any point during the lifetime of the pipeline. |
81 // | 88 // |
82 // It is safe to delete the pipeline during the execution of |stop_cb|. | 89 // It is safe to delete the pipeline during the execution of |stop_cb|. |
83 virtual void Stop(const base::Closure& stop_cb) = 0; | 90 virtual void Stop(const base::Closure& stop_cb) = 0; |
84 | 91 |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
155 // Gets the current pipeline statistics. | 162 // Gets the current pipeline statistics. |
156 virtual PipelineStatistics GetStatistics() const = 0; | 163 virtual PipelineStatistics GetStatistics() const = 0; |
157 | 164 |
158 virtual void SetCdm(CdmContext* cdm_context, | 165 virtual void SetCdm(CdmContext* cdm_context, |
159 const CdmAttachedCB& cdm_attached_cb) = 0; | 166 const CdmAttachedCB& cdm_attached_cb) = 0; |
160 }; | 167 }; |
161 | 168 |
162 } // namespace media | 169 } // namespace media |
163 | 170 |
164 #endif // MEDIA_BASE_PIPELINE_H_ | 171 #endif // MEDIA_BASE_PIPELINE_H_ |
OLD | NEW |