OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "chromecast/media/cma/ipc_streamer/coded_frame_provider_host.h" | 5 #include "chromecast/media/cma/ipc_streamer/coded_frame_provider_host.h" |
6 | 6 |
7 #include <utility> | 7 #include <utility> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/callback_helpers.h" | 10 #include "base/callback_helpers.h" |
11 #include "chromecast/media/cma/base/decoder_buffer_base.h" | 11 #include "chromecast/media/cma/base/decoder_buffer_base.h" |
12 #include "chromecast/media/cma/ipc/media_message.h" | 12 #include "chromecast/media/cma/ipc/media_message.h" |
13 #include "chromecast/media/cma/ipc/media_message_fifo.h" | 13 #include "chromecast/media/cma/ipc/media_message_fifo.h" |
14 #include "chromecast/media/cma/ipc/media_message_type.h" | 14 #include "chromecast/media/cma/ipc/media_message_type.h" |
15 #include "chromecast/media/cma/ipc_streamer/audio_decoder_config_marshaller.h" | 15 #include "chromecast/media/cma/ipc_streamer/audio_decoder_config_marshaller.h" |
16 #include "chromecast/media/cma/ipc_streamer/decoder_buffer_base_marshaller.h" | 16 #include "chromecast/media/cma/ipc_streamer/decoder_buffer_base_marshaller.h" |
17 #include "chromecast/media/cma/ipc_streamer/video_decoder_config_marshaller.h" | 17 #include "chromecast/media/cma/ipc_streamer/video_decoder_config_marshaller.h" |
18 #include "media/base/decrypt_config.h" | 18 #include "media/base/decrypt_config.h" |
19 | 19 |
20 namespace chromecast { | 20 namespace chromecast { |
21 namespace media { | 21 namespace media { |
22 | 22 |
23 CodedFrameProviderHost::CodedFrameProviderHost( | 23 CodedFrameProviderHost::CodedFrameProviderHost( |
24 scoped_ptr<MediaMessageFifo> media_message_fifo) | 24 std::unique_ptr<MediaMessageFifo> media_message_fifo) |
25 : fifo_(std::move(media_message_fifo)), weak_factory_(this) { | 25 : fifo_(std::move(media_message_fifo)), weak_factory_(this) { |
26 weak_this_ = weak_factory_.GetWeakPtr(); | 26 weak_this_ = weak_factory_.GetWeakPtr(); |
27 thread_checker_.DetachFromThread(); | 27 thread_checker_.DetachFromThread(); |
28 } | 28 } |
29 | 29 |
30 CodedFrameProviderHost::~CodedFrameProviderHost() { | 30 CodedFrameProviderHost::~CodedFrameProviderHost() { |
31 DCHECK(thread_checker_.CalledOnValidThread()); | 31 DCHECK(thread_checker_.CalledOnValidThread()); |
32 } | 32 } |
33 | 33 |
34 void CodedFrameProviderHost::Read(const ReadCB& read_cb) { | 34 void CodedFrameProviderHost::Read(const ReadCB& read_cb) { |
(...skipping 21 matching lines...) Expand all Loading... |
56 } | 56 } |
57 | 57 |
58 base::Closure CodedFrameProviderHost::GetFifoWriteEventCb() { | 58 base::Closure CodedFrameProviderHost::GetFifoWriteEventCb() { |
59 return base::Bind(&CodedFrameProviderHost::OnFifoWriteEvent, weak_this_); | 59 return base::Bind(&CodedFrameProviderHost::OnFifoWriteEvent, weak_this_); |
60 } | 60 } |
61 | 61 |
62 void CodedFrameProviderHost::ReadMessages() { | 62 void CodedFrameProviderHost::ReadMessages() { |
63 // Read messages until a frame is provided (i.e. not just the audio/video | 63 // Read messages until a frame is provided (i.e. not just the audio/video |
64 // configurations). | 64 // configurations). |
65 while (!read_cb_.is_null()) { | 65 while (!read_cb_.is_null()) { |
66 scoped_ptr<MediaMessage> msg(fifo_->Pop()); | 66 std::unique_ptr<MediaMessage> msg(fifo_->Pop()); |
67 if (!msg) | 67 if (!msg) |
68 break; | 68 break; |
69 | 69 |
70 if (msg->type() == PaddingMediaMsg) { | 70 if (msg->type() == PaddingMediaMsg) { |
71 // Ignore the message. | 71 // Ignore the message. |
72 } else if (msg->type() == AudioConfigMediaMsg) { | 72 } else if (msg->type() == AudioConfigMediaMsg) { |
73 audio_config_ = AudioDecoderConfigMarshaller::Read(msg.get()); | 73 audio_config_ = AudioDecoderConfigMarshaller::Read(msg.get()); |
74 } else if (msg->type() == VideoConfigMediaMsg) { | 74 } else if (msg->type() == VideoConfigMediaMsg) { |
75 video_config_ = VideoDecoderConfigMarshaller::Read(msg.get()); | 75 video_config_ = VideoDecoderConfigMarshaller::Read(msg.get()); |
76 } else if (msg->type() == FrameMediaMsg) { | 76 } else if (msg->type() == FrameMediaMsg) { |
(...skipping 10 matching lines...) Expand all Loading... |
87 // the fifo. Crash the browser process in this case to avoid further | 87 // the fifo. Crash the browser process in this case to avoid further |
88 // security implications (so do not use NOTREACHED which crashes only | 88 // security implications (so do not use NOTREACHED which crashes only |
89 // in debug builds). | 89 // in debug builds). |
90 LOG(FATAL) << "Unknown media message"; | 90 LOG(FATAL) << "Unknown media message"; |
91 } | 91 } |
92 } | 92 } |
93 } | 93 } |
94 | 94 |
95 } // namespace media | 95 } // namespace media |
96 } // namespace chromecast | 96 } // namespace chromecast |
OLD | NEW |