OLD | NEW |
| (Empty) |
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 | |
3 // found in the LICENSE file. | |
4 | |
5 // Filters are connected in a strongly typed manner, with downstream filters | |
6 // always reading data from upstream filters. Upstream filters have no clue | |
7 // who is actually reading from them, and return the results via callbacks. | |
8 // | |
9 // DemuxerStream(Video) <- VideoDecoder <- VideoRenderer | |
10 // DataSource <- Demuxer < | |
11 // DemuxerStream(Audio) <- AudioDecoder <- AudioRenderer | |
12 // | |
13 // Upstream -------------------------------------------------------> Downstream | |
14 // <- Reads flow this way | |
15 // Buffer assignments flow this way -> | |
16 // | |
17 // Every filter maintains a reference to the scheduler, who maintains data | |
18 // shared between filters (i.e., reference clock value, playback state). The | |
19 // scheduler is also responsible for scheduling filter tasks (i.e., a read on | |
20 // a VideoDecoder would result in scheduling a Decode task). Filters can also | |
21 // use the scheduler to signal errors and shutdown playback. | |
22 | |
23 #ifndef MEDIA_BASE_FILTERS_H_ | |
24 #define MEDIA_BASE_FILTERS_H_ | |
25 | |
26 #include "base/callback.h" | |
27 #include "base/memory/ref_counted.h" | |
28 #include "base/time.h" | |
29 #include "media/base/media_export.h" | |
30 #include "media/base/pipeline_status.h" | |
31 | |
32 namespace media { | |
33 | |
34 class FilterHost; | |
35 | |
36 class MEDIA_EXPORT Filter : public base::RefCountedThreadSafe<Filter> { | |
37 public: | |
38 Filter(); | |
39 | |
40 // Sets the host that owns this filter. The host holds a strong | |
41 // reference to the filter. The reference held by the host is guaranteed | |
42 // to be released before the host object is destroyed by the pipeline. | |
43 virtual void SetHost(FilterHost* host) = 0; | |
44 | |
45 // The pipeline has resumed playback. Filters can continue requesting reads. | |
46 // Filters may implement this method if they need to respond to this call. | |
47 virtual void Play(const base::Closure& callback) = 0; | |
48 | |
49 // The pipeline has paused playback. Filters should stop buffer exchange. | |
50 // Filters may implement this method if they need to respond to this call. | |
51 virtual void Pause(const base::Closure& callback) = 0; | |
52 | |
53 // The pipeline has been flushed. Filters should return buffer to owners. | |
54 // Filters may implement this method if they need to respond to this call. | |
55 virtual void Flush(const base::Closure& callback) = 0; | |
56 | |
57 // The pipeline is being stopped either as a result of an error or because | |
58 // the client called Stop(). | |
59 virtual void Stop(const base::Closure& callback) = 0; | |
60 | |
61 // The pipeline playback rate has been changed. Filters may implement this | |
62 // method if they need to respond to this call. | |
63 virtual void SetPlaybackRate(float playback_rate) = 0; | |
64 | |
65 // Carry out any actions required to seek to the given time, executing the | |
66 // callback upon completion. | |
67 virtual void Seek(base::TimeDelta time, const PipelineStatusCB& callback) = 0; | |
68 | |
69 protected: | |
70 // Only allow scoped_refptr<> to delete filters. | |
71 friend class base::RefCountedThreadSafe<Filter>; | |
72 virtual ~Filter(); | |
73 | |
74 private: | |
75 DISALLOW_COPY_AND_ASSIGN(Filter); | |
76 }; | |
77 | |
78 } // namespace media | |
79 | |
80 #endif // MEDIA_BASE_FILTERS_H_ | |
OLD | NEW |