diff options
author | sergeyu@chromium.org <sergeyu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-11-03 04:17:09 +0000 |
---|---|---|
committer | sergeyu@chromium.org <sergeyu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-11-03 04:17:09 +0000 |
commit | 14fd1a60acdd439f80bdfc0aeb86761ba649db79 (patch) | |
tree | 5bfbcefbd8776ca6a4d810a75601d8bf62d91a7c /remoting/protocol/rtp_writer.cc | |
parent | 07f1ceeabc0cf63ed8d7ae7aa8d1ff04dda02584 (diff) | |
download | chromium_src-14fd1a60acdd439f80bdfc0aeb86761ba649db79.zip chromium_src-14fd1a60acdd439f80bdfc0aeb86761ba649db79.tar.gz chromium_src-14fd1a60acdd439f80bdfc0aeb86761ba649db79.tar.bz2 |
Add VideoReader and VideoWriter interfaces.
Implemented VideoReader and VideoWriter for RTP and Protobuf.
BUG=53986
TEST=None
Review URL: http://codereview.chromium.org/4229003
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@64878 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'remoting/protocol/rtp_writer.cc')
-rw-r--r-- | remoting/protocol/rtp_writer.cc | 18 |
1 files changed, 11 insertions, 7 deletions
diff --git a/remoting/protocol/rtp_writer.cc b/remoting/protocol/rtp_writer.cc index a9df798..909a572 100644 --- a/remoting/protocol/rtp_writer.cc +++ b/remoting/protocol/rtp_writer.cc @@ -32,7 +32,7 @@ void RtpWriter::Init(net::Socket* rtp_socket, net::Socket* rtcp_socket) { rtcp_socket_ = rtcp_socket; } -void RtpWriter::SendPacket(const char* data, int packet_size, +void RtpWriter::SendPacket(const char* payload, int payload_size, uint32 timestamp) { RtpHeader header; header.padding = false; @@ -49,15 +49,15 @@ void RtpWriter::SendPacket(const char* data, int packet_size, // TODO(sergeyu): Add VP8 payload header. int position = 0; - while (position < packet_size) { + while (position < payload_size) { // Allocate buffer. - int size = std::max(kMtu, packet_size - position); - int header_size = GetRtpHeaderSize(header.sources) + size; + int size = std::min(kMtu, payload_size - position); + int header_size = GetRtpHeaderSize(header.sources); int total_size = size + header_size; net::IOBufferWithSize* buffer = new net::IOBufferWithSize(total_size); // Set marker if this is the last frame. - header.marker = (position + size) == packet_size; + header.marker = (position + size) == payload_size; // TODO(sergeyu): Handle sequence number wrapping. header.sequence_number = last_packet_number_; @@ -68,7 +68,7 @@ void RtpWriter::SendPacket(const char* data, int packet_size, header); // Copy data to the buffer. - memcpy(buffer->data() + header_size, data + position, size); + memcpy(buffer->data() + header_size, payload + position, size); // Send it. buffered_rtp_writer_->Write(buffer); @@ -76,7 +76,11 @@ void RtpWriter::SendPacket(const char* data, int packet_size, position += size; } - DCHECK_EQ(position, packet_size); + DCHECK_EQ(position, payload_size); +} + +int RtpWriter::GetPendingPackets() { + return buffered_rtp_writer_->GetBufferChunks(); } // Stop writing and drop pending data. Must be called from the same thread as |