OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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/rtp_video_reader.h" | 5 #include "remoting/protocol/rtp_video_reader.h" |
6 | 6 |
7 #include "base/task.h" | 7 #include "base/task.h" |
8 #include "remoting/proto/video.pb.h" | 8 #include "remoting/proto/video.pb.h" |
9 #include "remoting/protocol/session.h" | 9 #include "remoting/protocol/session.h" |
10 | 10 |
11 namespace remoting { | 11 namespace remoting { |
12 namespace protocol { | 12 namespace protocol { |
13 | 13 |
14 RtpVideoReader::RtpVideoReader() { } | 14 RtpVideoReader::RtpVideoReader() { } |
15 RtpVideoReader::~RtpVideoReader() { } | 15 RtpVideoReader::~RtpVideoReader() { } |
16 | 16 |
17 void RtpVideoReader::Init(protocol::Session* session, VideoStub* video_stub) { | 17 void RtpVideoReader::Init(protocol::Session* session, VideoStub* video_stub) { |
18 rtp_reader_.Init(session->video_rtp_channel(), | 18 rtp_reader_.Init(session->video_rtp_channel(), |
19 NewCallback(this, &RtpVideoReader::OnRtpPacket)); | 19 NewCallback(this, &RtpVideoReader::OnRtpPacket)); |
20 video_stub_ = video_stub; | 20 video_stub_ = video_stub; |
21 } | 21 } |
22 | 22 |
23 void RtpVideoReader::Close() { | 23 void RtpVideoReader::Close() { |
24 rtp_reader_.Close(); | 24 rtp_reader_.Close(); |
25 } | 25 } |
26 | 26 |
27 void RtpVideoReader::OnRtpPacket(const RtpPacket& rtp_packet) { | 27 void RtpVideoReader::OnRtpPacket(const RtpPacket& rtp_packet) { |
28 VideoPacket* packet = new VideoPacket(); | 28 VideoPacket* packet = new VideoPacket(); |
29 | 29 |
30 packet->set_data(rtp_packet.payload, rtp_packet.payload_size); | 30 packet->mutable_data()->resize(rtp_packet.payload().total_bytes()); |
| 31 rtp_packet.payload().CopyTo( |
| 32 const_cast<char*>(packet->mutable_data()->data()), |
| 33 packet->data().size()); |
| 34 |
31 packet->mutable_format()->set_encoding(VideoPacketFormat::ENCODING_VP8); | 35 packet->mutable_format()->set_encoding(VideoPacketFormat::ENCODING_VP8); |
32 packet->set_flags(rtp_packet.header.marker ? VideoPacket::LAST_PACKET : 0); | 36 packet->set_flags(rtp_packet.header().marker ? VideoPacket::LAST_PACKET : 0); |
33 | 37 |
34 video_stub_->ProcessVideoPacket(packet, new DeleteTask<VideoPacket>(packet)); | 38 video_stub_->ProcessVideoPacket(packet, new DeleteTask<VideoPacket>(packet)); |
35 } | 39 } |
36 | 40 |
37 } // namespace protocol | 41 } // namespace protocol |
38 } // namespace remoting | 42 } // namespace remoting |
OLD | NEW |