Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(505)

Side by Side Diff: remoting/protocol/video_reader.cc

Issue 577473002: Simplify VideoReader and VideoWriter (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 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 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 "remoting/protocol/video_reader.h" 5 #include "remoting/protocol/video_reader.h"
6 6
7 #include "remoting/protocol/session_config.h" 7 #include "base/bind.h"
8 #include "remoting/protocol/protobuf_video_reader.h" 8 #include "net/socket/stream_socket.h"
9 #include "remoting/base/constants.h"
10 #include "remoting/proto/video.pb.h"
11 #include "remoting/protocol/stream_channel_factory.h"
12 #include "remoting/protocol/video_stub.h"
9 13
10 namespace remoting { 14 namespace remoting {
11 namespace protocol { 15 namespace protocol {
12 16
13 VideoReader::~VideoReader() { } 17 VideoReader::VideoReader()
18 : ChannelDispatcherBase(kVideoChannelName),
Wez 2014/09/16 23:10:06 nit: Should the channel name be a parameter to the
Sergey Ulanov 2014/09/17 21:52:06 I don't think it needs to be - it's consistent wit
Wez 2014/09/18 00:23:54 Acknowledged.
19 video_stub_(NULL) {
20 }
14 21
15 // static 22 VideoReader::~VideoReader() {
16 scoped_ptr<VideoReader> VideoReader::Create(const SessionConfig& config) { 23 }
17 const ChannelConfig& video_config = config.video_config(); 24
18 if (video_config.transport == ChannelConfig::TRANSPORT_STREAM) { 25 void VideoReader::OnInitialized() {
19 if (video_config.codec == ChannelConfig::CODEC_VP8) { 26 reader_.Init(channel(), base::Bind(&VideoReader::OnNewData,
20 return scoped_ptr<VideoReader>( 27 base::Unretained(this)));
21 new ProtobufVideoReader(VideoPacketFormat::ENCODING_VP8)); 28 }
22 } else if (video_config.codec == ChannelConfig::CODEC_VP9) { 29
23 return scoped_ptr<VideoReader>( 30 void VideoReader::OnNewData(scoped_ptr<VideoPacket> packet,
24 new ProtobufVideoReader(VideoPacketFormat::ENCODING_VP9)); 31 const base::Closure& done_task) {
25 } else if (video_config.codec == ChannelConfig::CODEC_ZIP) { 32 video_stub_->ProcessVideoPacket(packet.Pass(), done_task);
26 return scoped_ptr<VideoReader>(
27 new ProtobufVideoReader(VideoPacketFormat::ENCODING_ZLIB));
28 } else if (video_config.codec == ChannelConfig::CODEC_VERBATIM) {
29 return scoped_ptr<VideoReader>(
30 new ProtobufVideoReader(VideoPacketFormat::ENCODING_VERBATIM));
31 }
32 }
33 NOTREACHED();
34 return scoped_ptr<VideoReader>();
35 } 33 }
36 34
37 } // namespace protocol 35 } // namespace protocol
38 } // namespace remoting 36 } // namespace remoting
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698