Implemented native file reader protocols for avformat so it uses CogSource to read files
This commit is contained in:
parent
66925054e9
commit
2426d7f7fd
7 changed files with 179 additions and 6 deletions
|
@ -71,7 +71,7 @@
|
||||||
830F0C1917FC523000042E8F /* rdt.h in Headers */ = {isa = PBXBuildFile; fileRef = 830F0C1517FC523000042E8F /* rdt.h */; };
|
830F0C1917FC523000042E8F /* rdt.h in Headers */ = {isa = PBXBuildFile; fileRef = 830F0C1517FC523000042E8F /* rdt.h */; };
|
||||||
830F0C1A17FC523000042E8F /* rtp.h in Headers */ = {isa = PBXBuildFile; fileRef = 830F0C1617FC523000042E8F /* rtp.h */; };
|
830F0C1A17FC523000042E8F /* rtp.h in Headers */ = {isa = PBXBuildFile; fileRef = 830F0C1617FC523000042E8F /* rtp.h */; };
|
||||||
830F0C1B17FC523000042E8F /* url.c in Sources */ = {isa = PBXBuildFile; fileRef = 830F0C1717FC523000042E8F /* url.c */; };
|
830F0C1B17FC523000042E8F /* url.c in Sources */ = {isa = PBXBuildFile; fileRef = 830F0C1717FC523000042E8F /* url.c */; };
|
||||||
830F0C1C17FC523000042E8F /* url.h in Headers */ = {isa = PBXBuildFile; fileRef = 830F0C1817FC523000042E8F /* url.h */; };
|
830F0C1C17FC523000042E8F /* url.h in Headers */ = {isa = PBXBuildFile; fileRef = 830F0C1817FC523000042E8F /* url.h */; settings = {ATTRIBUTES = (Public, ); }; };
|
||||||
830F0C2217FC527400042E8F /* atomic_gcc.h in Headers */ = {isa = PBXBuildFile; fileRef = 830F0C1D17FC527400042E8F /* atomic_gcc.h */; };
|
830F0C2217FC527400042E8F /* atomic_gcc.h in Headers */ = {isa = PBXBuildFile; fileRef = 830F0C1D17FC527400042E8F /* atomic_gcc.h */; };
|
||||||
830F0C2317FC527400042E8F /* atomic.c in Sources */ = {isa = PBXBuildFile; fileRef = 830F0C1E17FC527400042E8F /* atomic.c */; };
|
830F0C2317FC527400042E8F /* atomic.c in Sources */ = {isa = PBXBuildFile; fileRef = 830F0C1E17FC527400042E8F /* atomic.c */; };
|
||||||
830F0C2417FC527400042E8F /* atomic.h in Headers */ = {isa = PBXBuildFile; fileRef = 830F0C1F17FC527400042E8F /* atomic.h */; };
|
830F0C2417FC527400042E8F /* atomic.h in Headers */ = {isa = PBXBuildFile; fileRef = 830F0C1F17FC527400042E8F /* atomic.h */; };
|
||||||
|
@ -201,7 +201,7 @@
|
||||||
830F0D3117FC841B00042E8F /* imgutils.h in Headers */ = {isa = PBXBuildFile; fileRef = 830F0D2917FC841B00042E8F /* imgutils.h */; };
|
830F0D3117FC841B00042E8F /* imgutils.h in Headers */ = {isa = PBXBuildFile; fileRef = 830F0D2917FC841B00042E8F /* imgutils.h */; };
|
||||||
830F0D3217FC841B00042E8F /* intfloat_readwrite.c in Sources */ = {isa = PBXBuildFile; fileRef = 830F0D2A17FC841B00042E8F /* intfloat_readwrite.c */; };
|
830F0D3217FC841B00042E8F /* intfloat_readwrite.c in Sources */ = {isa = PBXBuildFile; fileRef = 830F0D2A17FC841B00042E8F /* intfloat_readwrite.c */; };
|
||||||
830F0D3317FC841B00042E8F /* opt.c in Sources */ = {isa = PBXBuildFile; fileRef = 830F0D2B17FC841B00042E8F /* opt.c */; };
|
830F0D3317FC841B00042E8F /* opt.c in Sources */ = {isa = PBXBuildFile; fileRef = 830F0D2B17FC841B00042E8F /* opt.c */; };
|
||||||
830F0D3417FC841B00042E8F /* opt.h in Headers */ = {isa = PBXBuildFile; fileRef = 830F0D2C17FC841B00042E8F /* opt.h */; };
|
830F0D3417FC841B00042E8F /* opt.h in Headers */ = {isa = PBXBuildFile; fileRef = 830F0D2C17FC841B00042E8F /* opt.h */; settings = {ATTRIBUTES = (Public, ); }; };
|
||||||
830F0D3517FC841B00042E8F /* samplefmt.c in Sources */ = {isa = PBXBuildFile; fileRef = 830F0D2D17FC841B00042E8F /* samplefmt.c */; };
|
830F0D3517FC841B00042E8F /* samplefmt.c in Sources */ = {isa = PBXBuildFile; fileRef = 830F0D2D17FC841B00042E8F /* samplefmt.c */; };
|
||||||
830F0D3817FC844E00042E8F /* parseutils.c in Sources */ = {isa = PBXBuildFile; fileRef = 830F0D3617FC844E00042E8F /* parseutils.c */; };
|
830F0D3817FC844E00042E8F /* parseutils.c in Sources */ = {isa = PBXBuildFile; fileRef = 830F0D3617FC844E00042E8F /* parseutils.c */; };
|
||||||
830F0D3917FC844E00042E8F /* parseutils.h in Headers */ = {isa = PBXBuildFile; fileRef = 830F0D3717FC844E00042E8F /* parseutils.h */; };
|
830F0D3917FC844E00042E8F /* parseutils.h in Headers */ = {isa = PBXBuildFile; fileRef = 830F0D3717FC844E00042E8F /* parseutils.h */; };
|
||||||
|
@ -979,6 +979,8 @@
|
||||||
isa = PBXHeadersBuildPhase;
|
isa = PBXHeadersBuildPhase;
|
||||||
buildActionMask = 2147483647;
|
buildActionMask = 2147483647;
|
||||||
files = (
|
files = (
|
||||||
|
830F0D3417FC841B00042E8F /* opt.h in Headers */,
|
||||||
|
830F0C1C17FC523000042E8F /* url.h in Headers */,
|
||||||
83BCB8E217FCA64400760340 /* avconfig.h in Headers */,
|
83BCB8E217FCA64400760340 /* avconfig.h in Headers */,
|
||||||
830F0BDC17FC4FB900042E8F /* old_codec_ids.h in Headers */,
|
830F0BDC17FC4FB900042E8F /* old_codec_ids.h in Headers */,
|
||||||
830F0C0B17FC4FB900042E8F /* pixfmt.h in Headers */,
|
830F0C0B17FC4FB900042E8F /* pixfmt.h in Headers */,
|
||||||
|
@ -1064,7 +1066,6 @@
|
||||||
830F0DCA17FC931700042E8F /* pcm.h in Headers */,
|
830F0DCA17FC931700042E8F /* pcm.h in Headers */,
|
||||||
830F0CCC17FC7F1E00042E8F /* celp_filters.h in Headers */,
|
830F0CCC17FC7F1E00042E8F /* celp_filters.h in Headers */,
|
||||||
830F0D5117FC880E00042E8F /* time_.h in Headers */,
|
830F0D5117FC880E00042E8F /* time_.h in Headers */,
|
||||||
830F0C1C17FC523000042E8F /* url.h in Headers */,
|
|
||||||
830F0BD717FC4FB900042E8F /* get_bits.h in Headers */,
|
830F0BD717FC4FB900042E8F /* get_bits.h in Headers */,
|
||||||
830F0C2417FC527400042E8F /* atomic.h in Headers */,
|
830F0C2417FC527400042E8F /* atomic.h in Headers */,
|
||||||
830F0C5D17FC7CEA00042E8F /* id3v1.h in Headers */,
|
830F0C5D17FC7CEA00042E8F /* id3v1.h in Headers */,
|
||||||
|
@ -1091,7 +1092,6 @@
|
||||||
830F0D4117FC848D00042E8F /* sha.h in Headers */,
|
830F0D4117FC848D00042E8F /* sha.h in Headers */,
|
||||||
830F0CEE17FC7F1E00042E8F /* mpeg12data.h in Headers */,
|
830F0CEE17FC7F1E00042E8F /* mpeg12data.h in Headers */,
|
||||||
830F0CE817FC7F1E00042E8F /* hpeldsp.h in Headers */,
|
830F0CE817FC7F1E00042E8F /* hpeldsp.h in Headers */,
|
||||||
830F0D3417FC841B00042E8F /* opt.h in Headers */,
|
|
||||||
830F0D8B17FC8E8B00042E8F /* aacpsdsp.h in Headers */,
|
830F0D8B17FC8E8B00042E8F /* aacpsdsp.h in Headers */,
|
||||||
830F0CD617FC7F1E00042E8F /* dctref.h in Headers */,
|
830F0CD617FC7F1E00042E8F /* dctref.h in Headers */,
|
||||||
830F0C1917FC523000042E8F /* rdt.h in Headers */,
|
830F0C1917FC523000042E8F /* rdt.h in Headers */,
|
||||||
|
|
|
@ -1035,7 +1035,7 @@
|
||||||
#define CONFIG_DATA_PROTOCOL 0
|
#define CONFIG_DATA_PROTOCOL 0
|
||||||
#define CONFIG_FFRTMPCRYPT_PROTOCOL 0
|
#define CONFIG_FFRTMPCRYPT_PROTOCOL 0
|
||||||
#define CONFIG_FFRTMPHTTP_PROTOCOL 0
|
#define CONFIG_FFRTMPHTTP_PROTOCOL 0
|
||||||
#define CONFIG_FILE_PROTOCOL 1
|
#define CONFIG_FILE_PROTOCOL 0
|
||||||
#define CONFIG_FTP_PROTOCOL 0
|
#define CONFIG_FTP_PROTOCOL 0
|
||||||
#define CONFIG_GOPHER_PROTOCOL 0
|
#define CONFIG_GOPHER_PROTOCOL 0
|
||||||
#define CONFIG_HLS_PROTOCOL 0
|
#define CONFIG_HLS_PROTOCOL 0
|
||||||
|
|
|
@ -26,10 +26,15 @@
|
||||||
#define AVFORMAT_URL_H
|
#define AVFORMAT_URL_H
|
||||||
|
|
||||||
#include "avio.h"
|
#include "avio.h"
|
||||||
|
#ifdef __FRAMEWORK__
|
||||||
|
#include "dict.h"
|
||||||
|
#include "log.h"
|
||||||
|
#else
|
||||||
#include "libavformat/version.h"
|
#include "libavformat/version.h"
|
||||||
|
|
||||||
#include "libavutil/dict.h"
|
#include "libavutil/dict.h"
|
||||||
#include "libavutil/log.h"
|
#include "libavutil/log.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
#define URL_PROTOCOL_FLAG_NESTED_SCHEME 1 /*< The protocol name can be the first part of a nested protocol scheme */
|
#define URL_PROTOCOL_FLAG_NESTED_SCHEME 1 /*< The protocol name can be the first part of a nested protocol scheme */
|
||||||
#define URL_PROTOCOL_FLAG_NETWORK 2 /*< The protocol uses network */
|
#define URL_PROTOCOL_FLAG_NETWORK 2 /*< The protocol uses network */
|
||||||
|
|
|
@ -7,6 +7,7 @@
|
||||||
objects = {
|
objects = {
|
||||||
|
|
||||||
/* Begin PBXBuildFile section */
|
/* Begin PBXBuildFile section */
|
||||||
|
834225D317FFBD2200DD3E2F /* WMAFileProtocols.m in Sources */ = {isa = PBXBuildFile; fileRef = 834225D217FFBD2200DD3E2F /* WMAFileProtocols.m */; };
|
||||||
8D5B49B4048680CD000E48DA /* Cocoa.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1058C7ADFEA557BF11CA2CBB /* Cocoa.framework */; };
|
8D5B49B4048680CD000E48DA /* Cocoa.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1058C7ADFEA557BF11CA2CBB /* Cocoa.framework */; };
|
||||||
B09E942F0D747F410064F138 /* WMADecoder.m in Sources */ = {isa = PBXBuildFile; fileRef = B09E942E0D747F410064F138 /* WMADecoder.m */; };
|
B09E942F0D747F410064F138 /* WMADecoder.m in Sources */ = {isa = PBXBuildFile; fileRef = B09E942E0D747F410064F138 /* WMADecoder.m */; };
|
||||||
B09E95560D749A780064F138 /* WMA.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = B09E95080D748F9B0064F138 /* WMA.framework */; };
|
B09E95560D749A780064F138 /* WMA.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = B09E95080D748F9B0064F138 /* WMA.framework */; };
|
||||||
|
@ -50,6 +51,8 @@
|
||||||
089C167FFE841241C02AAC07 /* AppKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AppKit.framework; path = /System/Library/Frameworks/AppKit.framework; sourceTree = "<absolute>"; };
|
089C167FFE841241C02AAC07 /* AppKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AppKit.framework; path = /System/Library/Frameworks/AppKit.framework; sourceTree = "<absolute>"; };
|
||||||
1058C7ADFEA557BF11CA2CBB /* Cocoa.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Cocoa.framework; path = /System/Library/Frameworks/Cocoa.framework; sourceTree = "<absolute>"; };
|
1058C7ADFEA557BF11CA2CBB /* Cocoa.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Cocoa.framework; path = /System/Library/Frameworks/Cocoa.framework; sourceTree = "<absolute>"; };
|
||||||
32DBCF630370AF2F00C91783 /* WMA_Prefix.pch */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WMA_Prefix.pch; sourceTree = "<group>"; };
|
32DBCF630370AF2F00C91783 /* WMA_Prefix.pch */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WMA_Prefix.pch; sourceTree = "<group>"; };
|
||||||
|
834225D117FFBD2200DD3E2F /* WMAFileProtocols.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WMAFileProtocols.h; sourceTree = "<group>"; };
|
||||||
|
834225D217FFBD2200DD3E2F /* WMAFileProtocols.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = WMAFileProtocols.m; sourceTree = "<group>"; };
|
||||||
8D5B49B6048680CD000E48DA /* WMA.bundle */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = WMA.bundle; sourceTree = BUILT_PRODUCTS_DIR; };
|
8D5B49B6048680CD000E48DA /* WMA.bundle */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = WMA.bundle; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||||
8D5B49B7048680CD000E48DA /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
|
8D5B49B7048680CD000E48DA /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
|
||||||
B09E942D0D747F410064F138 /* WMADecoder.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WMADecoder.h; sourceTree = "<group>"; };
|
B09E942D0D747F410064F138 /* WMADecoder.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WMADecoder.h; sourceTree = "<group>"; };
|
||||||
|
@ -106,6 +109,8 @@
|
||||||
08FB77AFFE84173DC02AAC07 /* Classes */ = {
|
08FB77AFFE84173DC02AAC07 /* Classes */ = {
|
||||||
isa = PBXGroup;
|
isa = PBXGroup;
|
||||||
children = (
|
children = (
|
||||||
|
834225D117FFBD2200DD3E2F /* WMAFileProtocols.h */,
|
||||||
|
834225D217FFBD2200DD3E2F /* WMAFileProtocols.m */,
|
||||||
B09E94370D747FAD0064F138 /* Plugin.h */,
|
B09E94370D747FAD0064F138 /* Plugin.h */,
|
||||||
B09E942D0D747F410064F138 /* WMADecoder.h */,
|
B09E942D0D747F410064F138 /* WMADecoder.h */,
|
||||||
B09E942E0D747F410064F138 /* WMADecoder.m */,
|
B09E942E0D747F410064F138 /* WMADecoder.m */,
|
||||||
|
@ -235,6 +240,7 @@
|
||||||
buildActionMask = 2147483647;
|
buildActionMask = 2147483647;
|
||||||
files = (
|
files = (
|
||||||
B09E942F0D747F410064F138 /* WMADecoder.m in Sources */,
|
B09E942F0D747F410064F138 /* WMADecoder.m in Sources */,
|
||||||
|
834225D317FFBD2200DD3E2F /* WMAFileProtocols.m in Sources */,
|
||||||
);
|
);
|
||||||
runOnlyForDeploymentPostprocessing = 0;
|
runOnlyForDeploymentPostprocessing = 0;
|
||||||
};
|
};
|
||||||
|
|
|
@ -8,6 +8,7 @@
|
||||||
|
|
||||||
// test
|
// test
|
||||||
#import "WMADecoder.h"
|
#import "WMADecoder.h"
|
||||||
|
#import "WMAFileProtocols.h"
|
||||||
|
|
||||||
#include <pthread.h>
|
#include <pthread.h>
|
||||||
|
|
||||||
|
@ -45,6 +46,7 @@ int lockmgr_callback(void ** mutex, enum AVLockOp op)
|
||||||
+ (void)initialize
|
+ (void)initialize
|
||||||
{
|
{
|
||||||
av_register_all();
|
av_register_all();
|
||||||
|
registerCogProtocols();
|
||||||
av_lockmgr_register(lockmgr_callback);
|
av_lockmgr_register(lockmgr_callback);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -54,7 +56,7 @@ int lockmgr_callback(void ** mutex, enum AVLockOp op)
|
||||||
|
|
||||||
|
|
||||||
int err, i;
|
int err, i;
|
||||||
const char *filename = [[[source url] path] UTF8String];
|
const char *filename = [[[[source url] absoluteString] stringByReplacingPercentEscapesUsingEncoding:NSUTF8StringEncoding] UTF8String];
|
||||||
|
|
||||||
ic = NULL;
|
ic = NULL;
|
||||||
numFrames = 0;
|
numFrames = 0;
|
||||||
|
|
15
Plugins/WMA/WMAFileProtocols.h
Normal file
15
Plugins/WMA/WMAFileProtocols.h
Normal file
|
@ -0,0 +1,15 @@
|
||||||
|
//
|
||||||
|
// WMAFileProtocols.h
|
||||||
|
// WMA
|
||||||
|
//
|
||||||
|
// Created by Christopher Snowhill on 10/4/13.
|
||||||
|
// Copyright 2013 __NoWork, Inc__. All rights reserved.
|
||||||
|
//
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
extern void registerCogProtocols();
|
||||||
|
#ifdef __cplusplus
|
||||||
|
};
|
||||||
|
#endif
|
145
Plugins/WMA/WMAFileProtocols.m
Normal file
145
Plugins/WMA/WMAFileProtocols.m
Normal file
|
@ -0,0 +1,145 @@
|
||||||
|
//
|
||||||
|
// WMAFileProtocols.m
|
||||||
|
// WMA
|
||||||
|
//
|
||||||
|
// Created by Christopher Snowhill on 10/4/13.
|
||||||
|
// Copyright 2013 __NoWork, Inc__. All rights reserved.
|
||||||
|
//
|
||||||
|
|
||||||
|
#include "Plugin.h"
|
||||||
|
|
||||||
|
#define __FRAMEWORK__
|
||||||
|
#import <WMA/avformat.h>
|
||||||
|
#import <WMA/url.h>
|
||||||
|
#import <WMA/opt.h>
|
||||||
|
#undef __FRAMEWORK__
|
||||||
|
|
||||||
|
/* standard file protocol */
|
||||||
|
|
||||||
|
typedef struct FileContext {
|
||||||
|
const AVClass *class;
|
||||||
|
id<CogSource> fd;
|
||||||
|
} FileContext;
|
||||||
|
|
||||||
|
static const AVOption file_options[] = {
|
||||||
|
{ NULL }
|
||||||
|
};
|
||||||
|
|
||||||
|
#define LIBAVUTIL_VERSION_MAJOR 52
|
||||||
|
#define LIBAVUTIL_VERSION_MINOR 46
|
||||||
|
#define LIBAVUTIL_VERSION_MICRO 100
|
||||||
|
|
||||||
|
#define AV_VERSION_INT(a, b, c) (a<<16 | b<<8 | c)
|
||||||
|
|
||||||
|
#define LIBAVUTIL_VERSION_INT AV_VERSION_INT(LIBAVUTIL_VERSION_MAJOR, \
|
||||||
|
LIBAVUTIL_VERSION_MINOR, \
|
||||||
|
LIBAVUTIL_VERSION_MICRO)
|
||||||
|
|
||||||
|
static const AVClass file_class = {
|
||||||
|
.class_name = "file",
|
||||||
|
.item_name = av_default_item_name,
|
||||||
|
.option = file_options,
|
||||||
|
.version = LIBAVUTIL_VERSION_INT,
|
||||||
|
};
|
||||||
|
|
||||||
|
static const AVClass http_class = {
|
||||||
|
.class_name = "http",
|
||||||
|
.item_name = av_default_item_name,
|
||||||
|
.option = file_options,
|
||||||
|
.version = LIBAVUTIL_VERSION_INT,
|
||||||
|
};
|
||||||
|
|
||||||
|
static const AVClass unpack_class = {
|
||||||
|
.class_name = "unpack",
|
||||||
|
.item_name = av_default_item_name,
|
||||||
|
.option = file_options,
|
||||||
|
.version = LIBAVUTIL_VERSION_INT,
|
||||||
|
};
|
||||||
|
|
||||||
|
static int file_read(URLContext *h, unsigned char *buf, int size)
|
||||||
|
{
|
||||||
|
FileContext *c = h->priv_data;
|
||||||
|
return [c->fd read:buf amount:size];
|
||||||
|
}
|
||||||
|
|
||||||
|
static int file_check(URLContext *h, int mask)
|
||||||
|
{
|
||||||
|
return mask & AVIO_FLAG_READ;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int file_open(URLContext *h, const char *filename, int flags)
|
||||||
|
{
|
||||||
|
FileContext *c = h->priv_data;
|
||||||
|
id<CogSource> fd;
|
||||||
|
|
||||||
|
if (flags & AVIO_FLAG_WRITE) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
NSString * urlString = [NSString stringWithUTF8String:filename];
|
||||||
|
NSURL * url = [NSURL URLWithString:[urlString stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]];
|
||||||
|
|
||||||
|
id audioSourceClass = NSClassFromString(@"AudioSource");
|
||||||
|
fd = [audioSourceClass audioSourceForURL:url];
|
||||||
|
|
||||||
|
if (![fd open:url])
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
c->fd = [fd retain];
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* XXX: use llseek */
|
||||||
|
static int64_t file_seek(URLContext *h, int64_t pos, int whence)
|
||||||
|
{
|
||||||
|
FileContext *c = h->priv_data;
|
||||||
|
return [c->fd seek:pos whence:whence] ? [c->fd tell] : -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int file_close(URLContext *h)
|
||||||
|
{
|
||||||
|
FileContext *c = h->priv_data;
|
||||||
|
[c->fd release];
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
URLProtocol ff_file_protocol = {
|
||||||
|
.name = "file",
|
||||||
|
.url_open = file_open,
|
||||||
|
.url_read = file_read,
|
||||||
|
.url_seek = file_seek,
|
||||||
|
.url_close = file_close,
|
||||||
|
.url_check = file_check,
|
||||||
|
.priv_data_size = sizeof(FileContext),
|
||||||
|
.priv_data_class = &file_class,
|
||||||
|
};
|
||||||
|
|
||||||
|
URLProtocol ff_http_protocol = {
|
||||||
|
.name = "http",
|
||||||
|
.url_open = file_open,
|
||||||
|
.url_read = file_read,
|
||||||
|
.url_seek = file_seek,
|
||||||
|
.url_close = file_close,
|
||||||
|
.url_check = file_check,
|
||||||
|
.priv_data_size = sizeof(FileContext),
|
||||||
|
.priv_data_class = &file_class,
|
||||||
|
};
|
||||||
|
|
||||||
|
URLProtocol ff_unpack_protocol = {
|
||||||
|
.name = "unpack",
|
||||||
|
.url_open = file_open,
|
||||||
|
.url_read = file_read,
|
||||||
|
.url_seek = file_seek,
|
||||||
|
.url_close = file_close,
|
||||||
|
.url_check = file_check,
|
||||||
|
.priv_data_size = sizeof(FileContext),
|
||||||
|
.priv_data_class = &file_class,
|
||||||
|
};
|
||||||
|
|
||||||
|
void registerCogProtocols()
|
||||||
|
{
|
||||||
|
ffurl_register_protocol(&ff_file_protocol, sizeof(ff_file_protocol));
|
||||||
|
ffurl_register_protocol(&ff_http_protocol, sizeof(ff_http_protocol));
|
||||||
|
ffurl_register_protocol(&ff_unpack_protocol, sizeof(ff_unpack_protocol));
|
||||||
|
}
|
Loading…
Reference in a new issue