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

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: post stop callback 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
« no previous file with comments | « media/base/mock_filters.cc ('k') | media/base/pipeline_impl.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 except when the error occurs during
33 // Start/Seek/Resume or Suspend. Those errors are reported via |seek_cb|
34 // and |suspend_cb| respectively.
35 virtual void OnError(PipelineStatus status) = 0;
36
37 // Executed whenever the media reaches the end.
38 virtual void OnEnded() = 0;
39
40 // Executed when the content duration, container video size, start time,
41 // and whether the content has audio and/or video in supported formats are
42 // known.
43 virtual void OnMetadata(PipelineMetadata metadata) = 0;
44
45 // Executed whenever there are changes in the buffering state of the
46 // pipeline.
47 virtual void OnBufferingStateChange(BufferingState state) = 0;
48
49 // Executed whenever the presentation duration changes.
50 virtual void OnDurationChange() = 0;
51
52 // Executed whenever a text track is added.
53 // The client is expected to create a TextTrack and call |done_cb|.
54 virtual void OnAddTextTrack(const TextTrackConfig& config,
55 const AddTextTrackDoneCB& done_cb) = 0;
56
57 // Executed whenever the key needed to decrypt the stream is not available.
58 virtual void OnWaitingForDecryptionKey() = 0;
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 // Methods on PipelineClient may be called up until Stop() has completed.
49 // The following permanent callbacks will be executed as follows up until
50 // Stop() has completed:
51 // |ended_cb| will be executed whenever the media reaches the end.
52 // |error_cb| will be executed whenever an error occurs but hasn't been
53 // reported already through another callback.
54 // |metadata_cb| will be executed when the content duration, container video
55 // size, start time, and whether the content has audio and/or
56 // video in supported formats are known.
57 // |buffering_state_cb| will be executed whenever there are changes in the
58 // overall buffering state of the pipeline.
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. 66 // It is an error to call this method after the pipeline has already started.
65 virtual void Start(Demuxer* demuxer, 67 virtual void Start(Demuxer* demuxer,
66 std::unique_ptr<Renderer> renderer, 68 std::unique_ptr<Renderer> renderer,
67 const base::Closure& ended_cb, 69 Client* client,
68 const PipelineStatusCB& error_cb, 70 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 71
76 // Asynchronously stops the pipeline, executing |stop_cb| when the pipeline 72 // Stops the pipeline. This is a blocking function.
77 // teardown has completed. 73 // If the pipeline is started, it must be stopped before destroying it.
74 // It it permissible to call Stop() at any point during the lifetime of the
75 // pipeline.
78 // 76 //
79 // Stop() must complete before destroying the pipeline. It it permissible to 77 // Once Stop is called any outstanding completion callbacks
80 // call Stop() at any point during the lifetime of the pipeline. 78 // for Start/Seek/Suspend/Resume or Client methods will *not* be called.
81 // 79 virtual void Stop() = 0;
82 // It is safe to delete the pipeline during the execution of |stop_cb|.
83 virtual void Stop(const base::Closure& stop_cb) = 0;
84 80
85 // Attempt to seek to the position specified by time. |seek_cb| will be 81 // 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. 82 // executed when the all filters in the pipeline have processed the seek.
87 // 83 //
88 // Clients are expected to call GetMediaTime() to check whether the seek 84 // Clients are expected to call GetMediaTime() to check whether the seek
89 // succeeded. 85 // succeeded.
90 // 86 //
91 // It is an error to call this method if the pipeline has not started or 87 // It is an error to call this method if the pipeline has not started or
92 // has been suspended. 88 // has been suspended.
93 virtual void Seek(base::TimeDelta time, const PipelineStatusCB& seek_cb) = 0; 89 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. 151 // Gets the current pipeline statistics.
156 virtual PipelineStatistics GetStatistics() const = 0; 152 virtual PipelineStatistics GetStatistics() const = 0;
157 153
158 virtual void SetCdm(CdmContext* cdm_context, 154 virtual void SetCdm(CdmContext* cdm_context,
159 const CdmAttachedCB& cdm_attached_cb) = 0; 155 const CdmAttachedCB& cdm_attached_cb) = 0;
160 }; 156 };
161 157
162 } // namespace media 158 } // namespace media
163 159
164 #endif // MEDIA_BASE_PIPELINE_H_ 160 #endif // MEDIA_BASE_PIPELINE_H_
OLDNEW
« no previous file with comments | « media/base/mock_filters.cc ('k') | media/base/pipeline_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698