Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(318)

Side by Side Diff: media/base/pipeline.h

Issue 1904793002: Move Pipeline permanent callbacks into Pipeline::Client interface. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: CHECK waiter PostTask Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 // Executed whenever an error occurs but hasn't been reported already
33 // through another callback.
xhwang 2016/05/04 06:32:22 What do you mean by "reported already through anot
alokp 2016/05/04 17:40:01 clarified.
34 virtual void OnError(PipelineStatus status) = 0;
35
36 // Executed whenever the media reaches the end.
37 virtual void OnEnded() = 0;
38
39 // Executed when the content duration, container video size, start time,
40 // and whether the content has audio and/or video in supported formats are
41 // known.
42 virtual void OnMetadata(PipelineMetadata metadata) = 0;
43
44 // Executed whenever there are changes in the buffering state of the
45 // pipeline.
46 virtual void OnBufferingStateChange(BufferingState state) = 0;
47
48 // Executed whenever the presentation duration changes.
49 virtual void OnDurationChange() = 0;
50
51 // Executed whenever a text track is added.
xhwang 2016/05/04 06:32:22 When should |done_cb| be fired?
alokp 2016/05/04 17:40:01 Added comment to the best of my knowledge. The old
52 virtual void OnAddTextTrack(const TextTrackConfig& config,
53 const AddTextTrackDoneCB& done_cb) = 0;
54
55 // Executed whenever the key needed to decrypt the stream is not available.
56 virtual void OnWaitingForDecryptionKey() = 0;
57 };
58
59 virtual ~Pipeline() {}
45 60
46 // Build a pipeline to using the given |demuxer| and |renderer| to construct 61 // 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. 62 // a filter chain, executing |seek_cb| when the initial seek has completed.
48 // 63 //
49 // The following permanent callbacks will be executed as follows up until 64 // The following permanent callbacks will be executed on PipelineClient up
50 // Stop() has completed: 65 // until Stop() has completed:
51 // |ended_cb| will be executed whenever the media reaches the end. 66 // OnError
52 // |error_cb| will be executed whenever an error occurs but hasn't been 67 // OnEnded
53 // reported already through another callback. 68 // OnMetadata
54 // |metadata_cb| will be executed when the content duration, container video 69 // OnBufferingStateChange
55 // size, start time, and whether the content has audio and/or 70 // OnDurationChange
56 // video in supported formats are known. 71 // OnAddTextTrack
57 // |buffering_state_cb| will be executed whenever there are changes in the 72 // OnWaitingForDecryptionKey
58 // overall buffering state of the pipeline. 73 //
xhwang 2016/05/04 06:32:22 These are calls on the Client interface, not reall
alokp 2016/05/04 17:40:01 Done.
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. 74 // It is an error to call this method after the pipeline has already started.
75 // TODO(xhwang): Rename |seek_cb| to |start_cb|.
xhwang 2016/05/04 06:32:22 Since Start/Seek/Resume all uses seek_cb, after a
alokp 2016/05/04 17:40:01 Done.
65 virtual void Start(Demuxer* demuxer, 76 virtual void Start(Demuxer* demuxer,
66 std::unique_ptr<Renderer> renderer, 77 std::unique_ptr<Renderer> renderer,
67 const base::Closure& ended_cb, 78 Client* client,
68 const PipelineStatusCB& error_cb, 79 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 80
76 // Asynchronously stops the pipeline, executing |stop_cb| when the pipeline 81 // Stops the pipeline. This is a blocking function.
77 // teardown has completed. 82 // The pipeline must be stopped before destroying it.
xhwang 2016/05/04 06:32:22 ... "if the pipeline is started" according to the
alokp 2016/05/04 17:40:01 Done.
83 // It it permissible to call Stop() at any point during the lifetime of the
84 // pipeline.
78 // 85 //
79 // Stop() must complete before destroying the pipeline. It it permissible to 86 // Once Stop is called any outstanding completion callbacks
80 // call Stop() at any point during the lifetime of the pipeline. 87 // for Start/Seek/Suspend/Resume or PipelineClient callbacks will *not*
xhwang 2016/05/04 06:32:22 s/PipelineClient/Client Since Client methods are
alokp 2016/05/04 17:40:01 Done.
81 // 88 // be called.
82 // It is safe to delete the pipeline during the execution of |stop_cb|. 89 virtual void Stop() = 0;
83 virtual void Stop(const base::Closure& stop_cb) = 0;
84 90
85 // Attempt to seek to the position specified by time. |seek_cb| will be 91 // Attempt to seek to the position specified by time. |seek_cb| will be
86 // executed when the all filters in the pipeline have processed the seek. 92 // executed when the all filters in the pipeline have processed the seek.
87 // 93 //
88 // Clients are expected to call GetMediaTime() to check whether the seek 94 // Clients are expected to call GetMediaTime() to check whether the seek
89 // succeeded. 95 // succeeded.
90 // 96 //
91 // It is an error to call this method if the pipeline has not started or 97 // It is an error to call this method if the pipeline has not started or
92 // has been suspended. 98 // has been suspended.
93 virtual void Seek(base::TimeDelta time, const PipelineStatusCB& seek_cb) = 0; 99 virtual void Seek(base::TimeDelta time, const PipelineStatusCB& seek_cb) = 0;
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
155 // Gets the current pipeline statistics. 161 // Gets the current pipeline statistics.
156 virtual PipelineStatistics GetStatistics() const = 0; 162 virtual PipelineStatistics GetStatistics() const = 0;
157 163
158 virtual void SetCdm(CdmContext* cdm_context, 164 virtual void SetCdm(CdmContext* cdm_context,
159 const CdmAttachedCB& cdm_attached_cb) = 0; 165 const CdmAttachedCB& cdm_attached_cb) = 0;
160 }; 166 };
161 167
162 } // namespace media 168 } // namespace media
163 169
164 #endif // MEDIA_BASE_PIPELINE_H_ 170 #endif // MEDIA_BASE_PIPELINE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698