OLD | NEW |
---|---|
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "media/ffmpeg/file_protocol.h" | 5 #include "media/ffmpeg/file_protocol.h" |
6 | 6 |
7 #include "build/build_config.h" | 7 #include "build/build_config.h" |
8 | 8 |
9 #if defined(OS_WIN) | 9 #if defined(OS_WIN) |
10 #include <io.h> | 10 #include <io.h> |
(...skipping 30 matching lines...) Expand all Loading... | |
41 | 41 |
42 int f = open(filename, access, 0666); | 42 int f = open(filename, access, 0666); |
43 if (f == -1) | 43 if (f == -1) |
44 return AVERROR(ENOENT); | 44 return AVERROR(ENOENT); |
45 | 45 |
46 h->priv_data = reinterpret_cast<void*>(static_cast<intptr_t>(f)); | 46 h->priv_data = reinterpret_cast<void*>(static_cast<intptr_t>(f)); |
47 h->is_streamed = false; | 47 h->is_streamed = false; |
48 return 0; | 48 return 0; |
49 } | 49 } |
50 | 50 |
51 static int Open2Context(URLContext* h, const char* filename, int flags, | |
52 AVDictionary **options) { | |
53 // TODO(dalecurtis): This is probably not right... | |
54 return OpenContext(h, filename, flags); | |
55 } | |
56 | |
51 static int ReadContext(URLContext* h, unsigned char* buf, int size) { | 57 static int ReadContext(URLContext* h, unsigned char* buf, int size) { |
52 return HANDLE_EINTR(read(GetHandle(h), buf, size)); | 58 return HANDLE_EINTR(read(GetHandle(h), buf, size)); |
53 } | 59 } |
54 | 60 |
55 #if LIBAVFORMAT_VERSION_INT >= AV_VERSION_INT(52, 68, 0) | 61 #if LIBAVFORMAT_VERSION_INT >= AV_VERSION_INT(52, 68, 0) |
56 static int WriteContext(URLContext* h, const unsigned char* buf, int size) { | 62 static int WriteContext(URLContext* h, const unsigned char* buf, int size) { |
57 #else | 63 #else |
58 static int WriteContext(URLContext* h, unsigned char* buf, int size) { | 64 static int WriteContext(URLContext* h, unsigned char* buf, int size) { |
59 #endif | 65 #endif |
60 return HANDLE_EINTR(write(GetHandle(h), buf, size)); | 66 return HANDLE_EINTR(write(GetHandle(h), buf, size)); |
(...skipping 10 matching lines...) Expand all Loading... | |
71 | 77 |
72 static int CloseContext(URLContext* h) { | 78 static int CloseContext(URLContext* h) { |
73 return HANDLE_EINTR(close(GetHandle(h))); | 79 return HANDLE_EINTR(close(GetHandle(h))); |
74 } | 80 } |
75 | 81 |
76 MSVC_POP_WARNING() | 82 MSVC_POP_WARNING() |
77 | 83 |
78 URLProtocol kFFmpegFileProtocol = { | 84 URLProtocol kFFmpegFileProtocol = { |
79 "file", | 85 "file", |
80 &OpenContext, | 86 &OpenContext, |
87 &Open2Context, | |
scherkus (not reviewing)
2012/02/06 21:13:49
is it acceptable to leave this as NULL?
DaleCurtis
2012/02/07 19:09:13
Done. Seemed to work fine.
| |
81 &ReadContext, | 88 &ReadContext, |
82 &WriteContext, | 89 &WriteContext, |
83 &SeekContext, | 90 &SeekContext, |
84 &CloseContext, | 91 &CloseContext, |
85 NULL, // *next | 92 NULL, // *next |
86 NULL, // url_read_pause | 93 NULL, // url_read_pause |
87 NULL, // url_read_seek | 94 NULL, // url_read_seek |
88 &GetHandle | 95 &GetHandle |
89 }; | 96 }; |
OLD | NEW |