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

Unified Diff: services/media/framework_ffmpeg/ffmpeg_io.cc

Issue 1814583002: Motown: New wrapper classes for ffmpeg format context and io context (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Tweaks based on feedback. Created 4 years, 9 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: services/media/framework_ffmpeg/ffmpeg_io.cc
diff --git a/services/media/framework_ffmpeg/ffmpeg_io.cc b/services/media/framework_ffmpeg/ffmpeg_io.cc
deleted file mode 100644
index c15c614d8511bc8cecf7a2d2fd67ee2b62535990..0000000000000000000000000000000000000000
--- a/services/media/framework_ffmpeg/ffmpeg_io.cc
+++ /dev/null
@@ -1,99 +0,0 @@
-// Copyright 2016 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 "base/logging.h"
-#include "services/media/framework/parts/reader.h"
-#include "services/media/framework_ffmpeg/ffmpeg_init.h"
-#include "services/media/framework_ffmpeg/ffmpeg_io.h"
-extern "C" {
-#include "third_party/ffmpeg/libavformat/avio.h"
-}
-
-namespace mojo {
-namespace media {
-
-static int AvioRead(void* opaque, uint8_t* buf, int buf_size);
-static int64_t AvioSeek(void* opaque, int64_t offset, int whence);
-
-AvioContextPtr CreateAvioContext(Reader* reader) {
- // Internal buffer size used by AVIO for reading.
- const int kBufferSize = 32 * 1024;
-
- InitFfmpeg();
-
- AVIOContext* result = avio_alloc_context(
- static_cast<unsigned char*>(av_malloc(kBufferSize)),
- kBufferSize,
- 0, // write_flag
- reader, // opaque
- &AvioRead,
- nullptr,
- &AvioSeek);
-
- // Ensure FFmpeg only tries to seek when we know how.
- result->seekable = reader->CanSeek() ? AVIO_SEEKABLE_NORMAL : 0;
-
- // Ensure writing is disabled.
- result->write_flag = 0;
-
- return AvioContextPtr(result);
-}
-
-// Performs a read operation using the signature required for avio.
-static int AvioRead(void* opaque, uint8_t* buf, int buf_size) {
- Reader* reader = reinterpret_cast<Reader*>(opaque);
- int result = reader->Read(buf, buf_size);
- if (result < 0) {
- result = AVERROR(EIO);
- }
- return result;
-}
-
-// Performs a seek operation using the signature required for avio.
-static int64_t AvioSeek(void* opaque, int64_t offset, int whence) {
- Reader* reader = reinterpret_cast<Reader*>(opaque);
-
- if (whence == AVSEEK_SIZE) {
- int64_t result = reader->GetSize();
- if (result == -1) {
- return AVERROR(EIO);
- }
- return result;
- }
-
- int64_t base;
- switch (whence) {
- case SEEK_SET:
- base = 0;
- break;
-
- case SEEK_CUR:
- base = reader->GetPosition();
- if (base == -1) {
- return AVERROR(EIO);
- }
- break;
-
- case SEEK_END:
- base = reader->GetSize();
- if (base == -1) {
- return AVERROR(EIO);
- }
- break;
-
- default:
- NOTREACHED();
- return AVERROR(EIO);
- }
-
- int64_t result = reader->SetPosition(base + offset);
- if (result == -1) {
- return AVERROR(EIO);
- }
-
- return result;
-}
-
-} // namespace media
-} // namespace mojo
« no previous file with comments | « services/media/framework_ffmpeg/ffmpeg_io.h ('k') | services/media/framework_ffmpeg/ffmpeg_type_converters.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698