OLD | NEW |
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. Use of this | 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. Use of this |
2 // source code is governed by a BSD-style license that can be found in the | 2 // source code is governed by a BSD-style license that can be found in the |
3 // LICENSE file. | 3 // LICENSE file. |
4 | 4 |
5 // VideoRendererBase creates its own thread for the sole purpose of timing frame | 5 // VideoRendererBase creates its own thread for the sole purpose of timing frame |
6 // presentation. It handles reading from the decoder and stores the results in | 6 // presentation. It handles reading from the decoder and stores the results in |
7 // a queue of decoded frames, calling OnFrameAvailable() on subclasses to notify | 7 // a queue of decoded frames, calling OnFrameAvailable() on subclasses to notify |
8 // when a frame is ready to display. | 8 // when a frame is ready to display. |
9 // | 9 // |
10 // The media filter methods Initialize(), Stop(), SetPlaybackRate() and Seek() | 10 // The media filter methods Initialize(), Stop(), SetPlaybackRate() and Seek() |
(...skipping 21 matching lines...) Expand all Loading... |
32 virtual ~VideoRendererBase(); | 32 virtual ~VideoRendererBase(); |
33 | 33 |
34 // Helper method for subclasses to parse out video-related information from | 34 // Helper method for subclasses to parse out video-related information from |
35 // a MediaFormat. Returns true if |width_out| and |height_out| were assigned. | 35 // a MediaFormat. Returns true if |width_out| and |height_out| were assigned. |
36 static bool ParseMediaFormat(const MediaFormat& media_format, | 36 static bool ParseMediaFormat(const MediaFormat& media_format, |
37 int* width_out, int* height_out); | 37 int* width_out, int* height_out); |
38 | 38 |
39 // MediaFilter implementation. | 39 // MediaFilter implementation. |
40 virtual void Stop(); | 40 virtual void Stop(); |
41 virtual void SetPlaybackRate(float playback_rate); | 41 virtual void SetPlaybackRate(float playback_rate); |
42 virtual void Seek(base::TimeDelta time); | 42 virtual void Seek(base::TimeDelta time, FilterCallback* callback); |
43 | 43 |
44 // VideoRenderer implementation. | 44 // VideoRenderer implementation. |
45 virtual bool Initialize(VideoDecoder* decoder); | 45 virtual void Initialize(VideoDecoder* decoder, FilterCallback* callback); |
46 | 46 |
47 // PlatformThread::Delegate implementation. | 47 // PlatformThread::Delegate implementation. |
48 virtual void ThreadMain(); | 48 virtual void ThreadMain(); |
49 | 49 |
50 // Assigns the current frame, which will never be NULL as long as this filter | 50 // Assigns the current frame, which will never be NULL as long as this filter |
51 // is initialized. | 51 // is initialized. |
52 void GetCurrentFrame(scoped_refptr<VideoFrame>* frame_out); | 52 void GetCurrentFrame(scoped_refptr<VideoFrame>* frame_out); |
53 | 53 |
54 protected: | 54 protected: |
55 // Subclass interface. Called before any other initialization in the base | 55 // Subclass interface. Called before any other initialization in the base |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
99 // Used to signal |thread_| as frames are added to |frames_|. Rule of thumb: | 99 // Used to signal |thread_| as frames are added to |frames_|. Rule of thumb: |
100 // always check |state_| to see if it was set to STOPPED after waking up! | 100 // always check |state_| to see if it was set to STOPPED after waking up! |
101 ConditionVariable frame_available_; | 101 ConditionVariable frame_available_; |
102 | 102 |
103 // Simple state tracking variable. | 103 // Simple state tracking variable. |
104 enum State { | 104 enum State { |
105 UNINITIALIZED, | 105 UNINITIALIZED, |
106 INITIALIZING, | 106 INITIALIZING, |
107 INITIALIZED, | 107 INITIALIZED, |
108 STOPPED, | 108 STOPPED, |
| 109 ERRORED, |
109 }; | 110 }; |
110 State state_; | 111 State state_; |
111 | 112 |
112 // Video thread handle. | 113 // Video thread handle. |
113 PlatformThreadHandle thread_; | 114 PlatformThreadHandle thread_; |
114 | 115 |
115 // Previous time returned from the pipeline. | 116 // Previous time returned from the pipeline. |
116 base::TimeDelta previous_time_; | 117 base::TimeDelta previous_time_; |
117 | 118 |
118 float playback_rate_; | 119 float playback_rate_; |
119 | 120 |
| 121 // Filter callbacks. |
| 122 scoped_ptr<FilterCallback> initialize_callback_; |
| 123 |
120 DISALLOW_COPY_AND_ASSIGN(VideoRendererBase); | 124 DISALLOW_COPY_AND_ASSIGN(VideoRendererBase); |
121 }; | 125 }; |
122 | 126 |
123 } // namespace media | 127 } // namespace media |
124 | 128 |
125 #endif // MEDIA_FILTERS_VIDEO_RENDERER_BASE_H_ | 129 #endif // MEDIA_FILTERS_VIDEO_RENDERER_BASE_H_ |
OLD | NEW |