OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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_CAST_CAST_ENVIRONMENT_H_ | 5 #ifndef MEDIA_CAST_CAST_ENVIRONMENT_H_ |
6 #define MEDIA_CAST_CAST_ENVIRONMENT_H_ | 6 #define MEDIA_CAST_CAST_ENVIRONMENT_H_ |
7 | 7 |
8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
9 #include "base/memory/ref_counted.h" | 9 #include "base/memory/ref_counted.h" |
10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
(...skipping 16 matching lines...) Expand all Loading... |
27 // The audio encoder thread is where all send side audio processing is done, | 27 // The audio encoder thread is where all send side audio processing is done, |
28 // primarily encoding but also re-sampling. | 28 // primarily encoding but also re-sampling. |
29 AUDIO_ENCODER, | 29 AUDIO_ENCODER, |
30 // The audio decoder thread is where all receive side audio processing is | 30 // The audio decoder thread is where all receive side audio processing is |
31 // done, primarily decoding but also error concealment and re-sampling. | 31 // done, primarily decoding but also error concealment and re-sampling. |
32 AUDIO_DECODER, | 32 AUDIO_DECODER, |
33 // The video encoder thread is where the video encode processing is done. | 33 // The video encoder thread is where the video encode processing is done. |
34 VIDEO_ENCODER, | 34 VIDEO_ENCODER, |
35 // The video decoder thread is where the video decode processing is done. | 35 // The video decoder thread is where the video decode processing is done. |
36 VIDEO_DECODER, | 36 VIDEO_DECODER, |
| 37 // The transport thread is where the transport processing is done. |
| 38 TRANSPORT, |
37 }; | 39 }; |
38 | 40 |
39 CastEnvironment(base::TickClock* clock, | 41 CastEnvironment(base::TickClock* clock, |
40 scoped_refptr<base::TaskRunner> main_thread_proxy, | 42 scoped_refptr<base::TaskRunner> main_thread_proxy, |
41 scoped_refptr<base::TaskRunner> audio_encode_thread_proxy, | 43 scoped_refptr<base::TaskRunner> audio_encode_thread_proxy, |
42 scoped_refptr<base::TaskRunner> audio_decode_thread_proxy, | 44 scoped_refptr<base::TaskRunner> audio_decode_thread_proxy, |
43 scoped_refptr<base::TaskRunner> video_encode_thread_proxy, | 45 scoped_refptr<base::TaskRunner> video_encode_thread_proxy, |
44 scoped_refptr<base::TaskRunner> video_decode_thread_proxy, | 46 scoped_refptr<base::TaskRunner> video_decode_thread_proxy, |
| 47 scoped_refptr<base::TaskRunner> transport_thread_proxy, |
45 const CastLoggingConfig& config); | 48 const CastLoggingConfig& config); |
46 | 49 |
47 // These are the same methods in message_loop.h, but are guaranteed to either | 50 // These are the same methods in message_loop.h, but are guaranteed to either |
48 // get posted to the MessageLoop if it's still alive, or be deleted otherwise. | 51 // get posted to the MessageLoop if it's still alive, or be deleted otherwise. |
49 // They return true iff the thread existed and the task was posted. Note that | 52 // They return true iff the thread existed and the task was posted. Note that |
50 // even if the task is posted, there's no guarantee that it will run, since | 53 // even if the task is posted, there's no guarantee that it will run, since |
51 // the target thread may already have a Quit message in its queue. | 54 // the target thread may already have a Quit message in its queue. |
52 bool PostTask(ThreadId identifier, | 55 bool PostTask(ThreadId identifier, |
53 const tracked_objects::Location& from_here, | 56 const tracked_objects::Location& from_here, |
54 const base::Closure& task); | 57 const base::Closure& task); |
55 | 58 |
56 bool PostDelayedTask(ThreadId identifier, | 59 bool PostDelayedTask(ThreadId identifier, |
57 const tracked_objects::Location& from_here, | 60 const tracked_objects::Location& from_here, |
58 const base::Closure& task, | 61 const base::Closure& task, |
59 base::TimeDelta delay); | 62 base::TimeDelta delay); |
60 | 63 |
61 bool CurrentlyOn(ThreadId identifier); | 64 bool CurrentlyOn(ThreadId identifier); |
62 | 65 |
63 base::TickClock* Clock() const; | 66 base::TickClock* Clock() const; |
64 | 67 |
65 // Logging is not thread safe. Should always be called from the main thread. | 68 // Logging is not thread safe. Should always be called from the main thread. |
66 LoggingImpl* Logging(); | 69 LoggingImpl* Logging(); |
67 | 70 |
| 71 scoped_refptr<base::TaskRunner> GetMessageTaskRunnerForThread( |
| 72 ThreadId identifier); |
| 73 |
68 protected: | 74 protected: |
69 virtual ~CastEnvironment(); | 75 virtual ~CastEnvironment(); |
70 | 76 |
71 private: | 77 private: |
72 friend class base::RefCountedThreadSafe<CastEnvironment>; | 78 friend class base::RefCountedThreadSafe<CastEnvironment>; |
73 | 79 |
74 scoped_refptr<base::TaskRunner> GetMessageTaskRunnerForThread( | |
75 ThreadId identifier); | |
76 | |
77 base::TickClock* const clock_; // Not owned by this class. | 80 base::TickClock* const clock_; // Not owned by this class. |
78 scoped_refptr<base::TaskRunner> main_thread_proxy_; | 81 scoped_refptr<base::TaskRunner> main_thread_proxy_; |
79 scoped_refptr<base::TaskRunner> audio_encode_thread_proxy_; | 82 scoped_refptr<base::TaskRunner> audio_encode_thread_proxy_; |
80 scoped_refptr<base::TaskRunner> audio_decode_thread_proxy_; | 83 scoped_refptr<base::TaskRunner> audio_decode_thread_proxy_; |
81 scoped_refptr<base::TaskRunner> video_encode_thread_proxy_; | 84 scoped_refptr<base::TaskRunner> video_encode_thread_proxy_; |
82 scoped_refptr<base::TaskRunner> video_decode_thread_proxy_; | 85 scoped_refptr<base::TaskRunner> video_decode_thread_proxy_; |
| 86 scoped_refptr<base::TaskRunner> transport_thread_proxy_; |
83 | 87 |
84 scoped_ptr<LoggingImpl> logging_; | 88 scoped_ptr<LoggingImpl> logging_; |
85 | 89 |
86 DISALLOW_COPY_AND_ASSIGN(CastEnvironment); | 90 DISALLOW_COPY_AND_ASSIGN(CastEnvironment); |
87 }; | 91 }; |
88 | 92 |
89 } // namespace cast | 93 } // namespace cast |
90 } // namespace media | 94 } // namespace media |
91 | 95 |
92 #endif // MEDIA_CAST_CAST_ENVIRONMENT_H_ | 96 #endif // MEDIA_CAST_CAST_ENVIRONMENT_H_ |
OLD | NEW |