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 #include "media/cast/cast_environment.h" | 5 #include "media/cast/cast_environment.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 | 8 |
9 using base::TaskRunner; | 9 using base::TaskRunner; |
10 | 10 |
11 namespace media { | 11 namespace media { |
12 namespace cast { | 12 namespace cast { |
13 | 13 |
14 CastEnvironment::CastEnvironment( | 14 CastEnvironment::CastEnvironment( |
15 base::TickClock* clock, | 15 base::TickClock* clock, |
16 scoped_refptr<TaskRunner> main_thread_proxy, | 16 scoped_refptr<TaskRunner> main_thread_proxy, |
17 scoped_refptr<TaskRunner> audio_encode_thread_proxy, | 17 scoped_refptr<TaskRunner> audio_encode_thread_proxy, |
18 scoped_refptr<TaskRunner> audio_decode_thread_proxy, | 18 scoped_refptr<TaskRunner> audio_decode_thread_proxy, |
19 scoped_refptr<TaskRunner> video_encode_thread_proxy, | 19 scoped_refptr<TaskRunner> video_encode_thread_proxy, |
20 scoped_refptr<TaskRunner> video_decode_thread_proxy, | 20 scoped_refptr<TaskRunner> video_decode_thread_proxy, |
21 scoped_refptr<TaskRunner> transport_thread_proxy, | |
22 const CastLoggingConfig& config) | 21 const CastLoggingConfig& config) |
23 : clock_(clock), | 22 : clock_(clock), |
24 main_thread_proxy_(main_thread_proxy), | 23 main_thread_proxy_(main_thread_proxy), |
25 audio_encode_thread_proxy_(audio_encode_thread_proxy), | 24 audio_encode_thread_proxy_(audio_encode_thread_proxy), |
26 audio_decode_thread_proxy_(audio_decode_thread_proxy), | 25 audio_decode_thread_proxy_(audio_decode_thread_proxy), |
27 video_encode_thread_proxy_(video_encode_thread_proxy), | 26 video_encode_thread_proxy_(video_encode_thread_proxy), |
28 video_decode_thread_proxy_(video_decode_thread_proxy), | 27 video_decode_thread_proxy_(video_decode_thread_proxy), |
29 transport_thread_proxy_(transport_thread_proxy), | |
30 logging_(new LoggingImpl(main_thread_proxy, config)) { | 28 logging_(new LoggingImpl(main_thread_proxy, config)) { |
31 DCHECK(main_thread_proxy) << "Main thread required"; | 29 DCHECK(main_thread_proxy) << "Main thread required"; |
32 } | 30 } |
33 | 31 |
34 CastEnvironment::~CastEnvironment() {} | 32 CastEnvironment::~CastEnvironment() {} |
35 | 33 |
36 bool CastEnvironment::PostTask(ThreadId identifier, | 34 bool CastEnvironment::PostTask(ThreadId identifier, |
37 const tracked_objects::Location& from_here, | 35 const tracked_objects::Location& from_here, |
38 const base::Closure& task) { | 36 const base::Closure& task) { |
39 scoped_refptr<TaskRunner> task_runner = | 37 scoped_refptr<TaskRunner> task_runner = |
(...skipping 18 matching lines...) Expand all Loading... |
58 case CastEnvironment::MAIN: | 56 case CastEnvironment::MAIN: |
59 return main_thread_proxy_; | 57 return main_thread_proxy_; |
60 case CastEnvironment::AUDIO_ENCODER: | 58 case CastEnvironment::AUDIO_ENCODER: |
61 return audio_encode_thread_proxy_; | 59 return audio_encode_thread_proxy_; |
62 case CastEnvironment::AUDIO_DECODER: | 60 case CastEnvironment::AUDIO_DECODER: |
63 return audio_decode_thread_proxy_; | 61 return audio_decode_thread_proxy_; |
64 case CastEnvironment::VIDEO_ENCODER: | 62 case CastEnvironment::VIDEO_ENCODER: |
65 return video_encode_thread_proxy_; | 63 return video_encode_thread_proxy_; |
66 case CastEnvironment::VIDEO_DECODER: | 64 case CastEnvironment::VIDEO_DECODER: |
67 return video_decode_thread_proxy_; | 65 return video_decode_thread_proxy_; |
68 case CastEnvironment::TRANSPORT: | |
69 return transport_thread_proxy_; | |
70 default: | 66 default: |
71 NOTREACHED() << "Invalid Thread identifier"; | 67 NOTREACHED() << "Invalid Thread identifier"; |
72 return NULL; | 68 return NULL; |
73 } | 69 } |
74 } | 70 } |
75 | 71 |
76 bool CastEnvironment::CurrentlyOn(ThreadId identifier) { | 72 bool CastEnvironment::CurrentlyOn(ThreadId identifier) { |
77 switch (identifier) { | 73 switch (identifier) { |
78 case CastEnvironment::MAIN: | 74 case CastEnvironment::MAIN: |
79 return main_thread_proxy_->RunsTasksOnCurrentThread(); | 75 return main_thread_proxy_->RunsTasksOnCurrentThread(); |
80 case CastEnvironment::AUDIO_ENCODER: | 76 case CastEnvironment::AUDIO_ENCODER: |
81 return audio_encode_thread_proxy_->RunsTasksOnCurrentThread(); | 77 return audio_encode_thread_proxy_->RunsTasksOnCurrentThread(); |
82 case CastEnvironment::AUDIO_DECODER: | 78 case CastEnvironment::AUDIO_DECODER: |
83 return audio_decode_thread_proxy_->RunsTasksOnCurrentThread(); | 79 return audio_decode_thread_proxy_->RunsTasksOnCurrentThread(); |
84 case CastEnvironment::VIDEO_ENCODER: | 80 case CastEnvironment::VIDEO_ENCODER: |
85 return video_encode_thread_proxy_->RunsTasksOnCurrentThread(); | 81 return video_encode_thread_proxy_->RunsTasksOnCurrentThread(); |
86 case CastEnvironment::VIDEO_DECODER: | 82 case CastEnvironment::VIDEO_DECODER: |
87 return video_decode_thread_proxy_->RunsTasksOnCurrentThread(); | 83 return video_decode_thread_proxy_->RunsTasksOnCurrentThread(); |
88 case CastEnvironment::TRANSPORT: | |
89 return transport_thread_proxy_->RunsTasksOnCurrentThread(); | |
90 default: | 84 default: |
91 NOTREACHED() << "Invalid thread identifier"; | 85 NOTREACHED() << "Invalid thread identifier"; |
92 return false; | 86 return false; |
93 } | 87 } |
94 } | 88 } |
95 | 89 |
96 base::TickClock* CastEnvironment::Clock() const { | 90 base::TickClock* CastEnvironment::Clock() const { |
97 return clock_; | 91 return clock_; |
98 } | 92 } |
99 | 93 |
100 LoggingImpl* CastEnvironment::Logging() { | 94 LoggingImpl* CastEnvironment::Logging() { |
101 DCHECK(CurrentlyOn(CastEnvironment::MAIN)) << | 95 DCHECK(CurrentlyOn(CastEnvironment::MAIN)) << |
102 "Must be called from main thread"; | 96 "Must be called from main thread"; |
103 return logging_.get(); | 97 return logging_.get(); |
104 } | 98 } |
105 | 99 |
106 } // namespace cast | 100 } // namespace cast |
107 } // namespace media | 101 } // namespace media |
OLD | NEW |