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

Unified Diff: remoting/protocol/rtp_writer.cc

Issue 4229003: Add VideoReader and VideoWriter interfaces. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: - Created 10 years, 1 month 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « remoting/protocol/rtp_writer.h ('k') | remoting/protocol/stream_writer.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: remoting/protocol/rtp_writer.cc
diff --git a/remoting/protocol/rtp_writer.cc b/remoting/protocol/rtp_writer.cc
index a9df79822aba12937fa6255311d37013e82ea668..909a572bc2ea98e76f6e19472d95abed9a62aea7 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
« no previous file with comments | « remoting/protocol/rtp_writer.h ('k') | remoting/protocol/stream_writer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698