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

Unified Diff: media/filters/buffer_url_protocol.cc

Issue 7203002: Adding ChunkDemuxer implementation. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Address CR comments Created 9 years, 6 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 side-by-side diff with in-line comments
Download patch
Index: media/filters/buffer_url_protocol.cc
diff --git a/media/filters/buffer_url_protocol.cc b/media/filters/buffer_url_protocol.cc
new file mode 100644
index 0000000000000000000000000000000000000000..d1970cdb63c493c8986e3769584999130f11da4c
--- /dev/null
+++ b/media/filters/buffer_url_protocol.cc
@@ -0,0 +1,55 @@
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "media/filters/buffer_url_protocol.h"
+
+namespace media {
+
+BufferUrlProtocol::BufferUrlProtocol(const uint8* buf, int size,
+ bool streaming)
+ : buf_(buf),
+ size_(size),
+ offset_(0),
+ streaming_(streaming) {
+}
+
+BufferUrlProtocol::~BufferUrlProtocol() {}
+
+int BufferUrlProtocol::Read(int size, uint8* data) {
+ int bytes_to_copy = size;
+ int bytes_left = size_ - offset_;
+
+ if (bytes_to_copy > bytes_left)
+ bytes_to_copy = bytes_left;
+
+ if (bytes_to_copy == 0)
+ return 0;
+
+ memcpy(data, buf_ + offset_, bytes_to_copy);
+ offset_ += bytes_to_copy;
+
+ return bytes_to_copy;
+}
+
+bool BufferUrlProtocol::GetPosition(int64* position_out) {
+ *position_out = offset_;
+ return true;
+}
+
+bool BufferUrlProtocol::SetPosition(int64 position) {
+ if (position < 0 || position >= size_)
+ return false;
+
+ offset_ = position;
+ return true;
+}
+
+bool BufferUrlProtocol::GetSize(int64* size_out) {
+ *size_out = size_;
+ return true;
+}
+
+bool BufferUrlProtocol::IsStreaming() { return streaming_; }
+
+} // namespace media

Powered by Google App Engine
This is Rietveld 408576698