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

Unified Diff: media/filters/in_memory_url_protocol.cc

Issue 7203002: Adding ChunkDemuxer implementation. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fixed unit tests and nits 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
« no previous file with comments | « media/filters/in_memory_url_protocol.h ('k') | media/media.gyp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: media/filters/in_memory_url_protocol.cc
diff --git a/media/filters/in_memory_url_protocol.cc b/media/filters/in_memory_url_protocol.cc
new file mode 100644
index 0000000000000000000000000000000000000000..dd7d984bac34b259ebdff08edc7d735fb4ec7de5
--- /dev/null
+++ b/media/filters/in_memory_url_protocol.cc
@@ -0,0 +1,59 @@
+// 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/in_memory_url_protocol.h"
+
+namespace media {
+
+InMemoryUrlProtocol::InMemoryUrlProtocol(const uint8* data, int64 size,
+ bool streaming)
+ : data_(data),
+ size_(size),
+ position_(0),
+ streaming_(streaming) {
+}
+
+InMemoryUrlProtocol::~InMemoryUrlProtocol() {}
+
+int InMemoryUrlProtocol::Read(int size, uint8* data) {
+ if (size < 0)
+ return -1;
+
+ int available_bytes = static_cast<int>(size_ - position_);
+ if (size > available_bytes)
+ size = available_bytes;
+
+ memcpy(data, data_ + position_, size);
+ position_ += size;
+ return size;
+}
+
+bool InMemoryUrlProtocol::GetPosition(int64* position_out) {
+ if (!position_out)
+ return false;
+
+ *position_out = position_;
+ return true;
+}
+
+bool InMemoryUrlProtocol::SetPosition(int64 position) {
+ if (position < 0 || position >= size_)
+ return false;
+ position_ = position;
+ return true;
+}
+
+bool InMemoryUrlProtocol::GetSize(int64* size_out) {
+ if (!size_out)
+ return false;
+
+ *size_out = size_;
+ return true;
+}
+
+bool InMemoryUrlProtocol::IsStreaming() {
+ return streaming_;
+}
+
+} // namespace media
« no previous file with comments | « media/filters/in_memory_url_protocol.h ('k') | media/media.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698