提交 eda8faf0 编写于 作者: Z Zhang Rui

ios: ijksdl: implement AudioUnit aout

上级 a6871781
......@@ -37,6 +37,7 @@
/* Begin PBXFileReference section */
E6166C7017EDA43C0006B956 /* libIJKMediaPlayer.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libIJKMediaPlayer.a; path = "../../../../../Library/Developer/Xcode/DerivedData/IJKMedia-earrwrzhlmypuheegnwtfewujljd/Build/Products/Debug-iphoneos/libIJKMediaPlayer.a"; sourceTree = "<group>"; };
E6166C9B17EDA4A20006B956 /* IJKMediaDemo-Prefix.pch */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "IJKMediaDemo-Prefix.pch"; sourceTree = "<group>"; };
E63FC27817F032FD003551EB /* IJKCommon.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = IJKCommon.h; sourceTree = "<group>"; };
E66F8DC917EEDD8B00354D80 /* IJKMediaControl.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = IJKMediaControl.h; sourceTree = "<group>"; };
E66F8DCA17EEDD8B00354D80 /* IJKMediaControl.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = IJKMediaControl.m; sourceTree = "<group>"; };
E66F8DCD17EEDFCA00354D80 /* player_top_control_bg.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = player_top_control_bg.png; path = resources/player_top_control_bg.png; sourceTree = "<group>"; };
......@@ -83,6 +84,14 @@
/* End PBXFrameworksBuildPhase section */
/* Begin PBXGroup section */
E63FC27717F032D9003551EB /* Misc */ = {
isa = PBXGroup;
children = (
E63FC27817F032FD003551EB /* IJKCommon.h */,
);
name = Misc;
sourceTree = "<group>";
};
E66F8DCC17EEDF8E00354D80 /* Resources */ = {
isa = PBXGroup;
children = (
......@@ -135,6 +144,7 @@
E6903F0E17EAF70200CFD954 /* IJKAppDelegate.h */,
E6903F0F17EAF70200CFD954 /* IJKAppDelegate.m */,
E6A9B55C17EDA6AC00A1A500 /* View Controllers */,
E63FC27717F032D9003551EB /* Misc */,
E66F8DCC17EEDF8E00354D80 /* Resources */,
E6903F0617EAF70200CFD954 /* Supporting Files */,
);
......
//
// IJKCommon.h
// IJKMediaDemo
//
// Created by ZhangRui on 13-9-23.
// Copyright (c) 2013年 bilibili. All rights reserved.
//
#import <Foundation/Foundation.h>
#define IOS_OLDER_THAN_6 ( [ [ [ UIDevice currentDevice ] systemVersion ] floatValue ] < 6.0 )
#define IOS_NEWER_OR_EQUAL_TO_6 ( [ [ [ UIDevice currentDevice ] systemVersion ] floatValue ] >= 6.0 )
......@@ -8,6 +8,7 @@
#import "IJKVideoViewController.h"
#import "IJKMediaControl.h"
#import "IJKCommon.h"
@implementation IJKVideoViewController
......@@ -35,6 +36,7 @@
// Do any additional setup after loading the view from its nib.
[[UIApplication sharedApplication] setStatusBarHidden:YES];
[[UIApplication sharedApplication] setStatusBarOrientation:UIInterfaceOrientationLandscapeLeft animated:NO];
NSURL *theMovieURL = [NSURL URLWithString:@"http://devimages.apple.com/iphone/samples/bipbop/gear1/prog_index.m3u8"];
self.player = [[IJKMPMoviePlayerController alloc] initWithContentURL:theMovieURL];
......@@ -49,11 +51,19 @@
[self.player play];
}
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation{
return UIInterfaceOrientationIsLandscape(toInterfaceOrientation);
}
- (NSUInteger)supportedInterfaceOrientations
{
return UIInterfaceOrientationMaskLandscape;
}
- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation{
return UIInterfaceOrientationLandscapeLeft;
}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
......
......@@ -39,6 +39,8 @@
<int key="NSvFlags">274</int>
<string key="NSFrameSize">{480, 320}</string>
<reference key="NSSuperview"/>
<reference key="NSWindow"/>
<reference key="NSNextKeyView"/>
<object class="NSColor" key="IBUIBackgroundColor" id="836798887">
<int key="NSColorSpace">3</int>
<bytes key="NSWhite">MCAwAA</bytes>
......@@ -70,6 +72,7 @@
<int key="NSvFlags">290</int>
<string key="NSFrameSize">{480, 44}</string>
<reference key="NSSuperview" ref="808249026"/>
<reference key="NSWindow"/>
<reference key="NSNextKeyView" ref="886045810"/>
<string key="NSReuseIdentifierKey">_NS:9</string>
<string key="NSHuggingPriority">{489, 250}</string>
......@@ -89,6 +92,7 @@
<int key="NSvFlags">292</int>
<string key="NSFrame">{{0, 2}, {60, 42}}</string>
<reference key="NSSuperview" ref="808249026"/>
<reference key="NSWindow"/>
<reference key="NSNextKeyView" ref="857327256"/>
<string key="NSReuseIdentifierKey">_NS:9</string>
<bool key="IBUIOpaque">NO</bool>
......@@ -124,6 +128,7 @@
</array>
<string key="NSFrameSize">{480, 44}</string>
<reference key="NSSuperview" ref="866126548"/>
<reference key="NSWindow"/>
<reference key="NSNextKeyView" ref="1036723062"/>
<string key="NSReuseIdentifierKey">_NS:9</string>
<reference key="IBUIBackgroundColor" ref="836798887"/>
......@@ -131,13 +136,14 @@
</object>
<object class="IBUIView" id="857327256">
<reference key="NSNextResponder" ref="866126548"/>
<int key="NSvFlags">274</int>
<int key="NSvFlags">266</int>
<array class="NSMutableArray" key="NSSubviews">
<object class="IBUIImageView" id="104184963">
<reference key="NSNextResponder" ref="857327256"/>
<int key="NSvFlags">274</int>
<int key="NSvFlags">258</int>
<string key="NSFrameSize">{400, 100}</string>
<reference key="NSSuperview" ref="857327256"/>
<reference key="NSWindow"/>
<reference key="NSNextKeyView" ref="235885398"/>
<string key="NSReuseIdentifierKey">_NS:9</string>
<bool key="IBUIUserInteractionEnabled">NO</bool>
......@@ -152,6 +158,7 @@
<int key="NSvFlags">293</int>
<string key="NSFrame">{{170, 2}, {60, 50}}</string>
<reference key="NSSuperview" ref="857327256"/>
<reference key="NSWindow"/>
<reference key="NSNextKeyView" ref="690132438"/>
<string key="NSReuseIdentifierKey">_NS:9</string>
<bool key="IBUIOpaque">NO</bool>
......@@ -176,6 +183,7 @@
<int key="NSvFlags">293</int>
<string key="NSFrame">{{170, 2}, {60, 50}}</string>
<reference key="NSSuperview" ref="857327256"/>
<reference key="NSWindow"/>
<reference key="NSNextKeyView" ref="811124737"/>
<string key="NSReuseIdentifierKey">_NS:9</string>
<bool key="IBUIOpaque">NO</bool>
......@@ -198,8 +206,9 @@
<object class="IBUISlider" id="85813162">
<reference key="NSNextResponder" ref="857327256"/>
<int key="NSvFlags">266</int>
<string key="NSFrame">{{66, 61}, {268, 23}}</string>
<string key="NSFrame">{{68, 61}, {264, 23}}</string>
<reference key="NSSuperview" ref="857327256"/>
<reference key="NSWindow"/>
<reference key="NSNextKeyView" ref="876706682"/>
<string key="NSReuseIdentifierKey">_NS:9</string>
<bool key="IBUIOpaque">NO</bool>
......@@ -211,8 +220,9 @@
<object class="IBUILabel" id="811124737">
<reference key="NSNextResponder" ref="857327256"/>
<int key="NSvFlags">268</int>
<string key="NSFrame">{{20, 61}, {43, 21}}</string>
<string key="NSFrame">{{20, 61}, {50, 21}}</string>
<reference key="NSSuperview" ref="857327256"/>
<reference key="NSWindow"/>
<reference key="NSNextKeyView" ref="85813162"/>
<string key="NSReuseIdentifierKey">_NS:9</string>
<bool key="IBUIOpaque">NO</bool>
......@@ -244,8 +254,10 @@
<object class="IBUILabel" id="876706682">
<reference key="NSNextResponder" ref="857327256"/>
<int key="NSvFlags">265</int>
<string key="NSFrame">{{337, 61}, {43, 21}}</string>
<string key="NSFrame">{{330, 61}, {50, 21}}</string>
<reference key="NSSuperview" ref="857327256"/>
<reference key="NSWindow"/>
<reference key="NSNextKeyView"/>
<string key="NSReuseIdentifierKey">_NS:9</string>
<bool key="IBUIOpaque">NO</bool>
<bool key="IBUIClipsSubviews">YES</bool>
......@@ -260,6 +272,7 @@
</object>
<nil key="IBUIHighlightedColor"/>
<int key="IBUIBaselineAdjustment">0</int>
<int key="IBUITextAlignment">2</int>
<reference key="IBUIFontDescription" ref="94318265"/>
<reference key="IBUIFont" ref="583023529"/>
<bool key="IBUIAdjustsFontSizeToFit">NO</bool>
......@@ -267,6 +280,7 @@
</array>
<string key="NSFrame">{{40, 200}, {400, 100}}</string>
<reference key="NSSuperview" ref="866126548"/>
<reference key="NSWindow"/>
<reference key="NSNextKeyView" ref="104184963"/>
<string key="NSReuseIdentifierKey">_NS:9</string>
<reference key="IBUIBackgroundColor" ref="836798887"/>
......@@ -275,6 +289,7 @@
</array>
<string key="NSFrameSize">{480, 320}</string>
<reference key="NSSuperview" ref="559262302"/>
<reference key="NSWindow"/>
<reference key="NSNextKeyView" ref="808249026"/>
<string key="NSReuseIdentifierKey">_NS:9</string>
<reference key="IBUIBackgroundColor" ref="836798887"/>
......@@ -283,6 +298,7 @@
</array>
<string key="NSFrameSize">{480, 320}</string>
<reference key="NSSuperview"/>
<reference key="NSWindow"/>
<reference key="NSNextKeyView" ref="866126548"/>
<string key="NSReuseIdentifierKey">_NS:9</string>
<reference key="IBUIBackgroundColor" ref="836798887"/>
......@@ -483,6 +499,7 @@
<object class="IBObjectRecord">
<int key="objectID">19</int>
<reference key="object" ref="886045810"/>
<array class="NSMutableArray" key="children"/>
<reference key="parent" ref="808249026"/>
<string key="objectName">Button: Back</string>
</object>
......@@ -503,6 +520,7 @@
<object class="IBObjectRecord">
<int key="objectID">42</int>
<reference key="object" ref="85813162"/>
<array class="NSMutableArray" key="children"/>
<reference key="parent" ref="857327256"/>
<string key="objectName">Slider: Video Progress</string>
</object>
......@@ -521,12 +539,14 @@
<object class="IBObjectRecord">
<int key="objectID">41</int>
<reference key="object" ref="690132438"/>
<array class="NSMutableArray" key="children"/>
<reference key="parent" ref="857327256"/>
<string key="objectName">Button: Pause</string>
</object>
<object class="IBObjectRecord">
<int key="objectID">40</int>
<reference key="object" ref="235885398"/>
<array class="NSMutableArray" key="children"/>
<reference key="parent" ref="857327256"/>
<string key="objectName">Button: Play</string>
</object>
......@@ -563,9 +583,112 @@
<nil key="activeLocalization"/>
<dictionary class="NSMutableDictionary" key="localizations"/>
<nil key="sourceID"/>
<int key="maxID">66</int>
<int key="maxID">103</int>
</object>
<object class="IBClassDescriber" key="IBDocument.Classes">
<array class="NSMutableArray" key="referencedPartialClassDescriptions">
<object class="IBPartialClassDescription">
<string key="className">IJKMediaControl</string>
<string key="superclassName">UIControl</string>
<dictionary class="NSMutableDictionary" key="outlets">
<string key="bottomPanel">UIView</string>
<string key="currentTimeLabel">UILabel</string>
<string key="mediaProgressSlider">UISlider</string>
<string key="overlayPanel">UIView</string>
<string key="pauseButton">UIButton</string>
<string key="playButton">UIButton</string>
<string key="topPanel">UIView</string>
<string key="totalDurationLabel">UILabel</string>
</dictionary>
<dictionary class="NSMutableDictionary" key="toOneOutletInfosByName">
<object class="IBToOneOutletInfo" key="bottomPanel">
<string key="name">bottomPanel</string>
<string key="candidateClassName">UIView</string>
</object>
<object class="IBToOneOutletInfo" key="currentTimeLabel">
<string key="name">currentTimeLabel</string>
<string key="candidateClassName">UILabel</string>
</object>
<object class="IBToOneOutletInfo" key="mediaProgressSlider">
<string key="name">mediaProgressSlider</string>
<string key="candidateClassName">UISlider</string>
</object>
<object class="IBToOneOutletInfo" key="overlayPanel">
<string key="name">overlayPanel</string>
<string key="candidateClassName">UIView</string>
</object>
<object class="IBToOneOutletInfo" key="pauseButton">
<string key="name">pauseButton</string>
<string key="candidateClassName">UIButton</string>
</object>
<object class="IBToOneOutletInfo" key="playButton">
<string key="name">playButton</string>
<string key="candidateClassName">UIButton</string>
</object>
<object class="IBToOneOutletInfo" key="topPanel">
<string key="name">topPanel</string>
<string key="candidateClassName">UIView</string>
</object>
<object class="IBToOneOutletInfo" key="totalDurationLabel">
<string key="name">totalDurationLabel</string>
<string key="candidateClassName">UILabel</string>
</object>
</dictionary>
<object class="IBClassDescriptionSource" key="sourceIdentifier">
<string key="majorKey">IBProjectSource</string>
<string key="minorKey">./Classes/IJKMediaControl.h</string>
</object>
</object>
<object class="IBPartialClassDescription">
<string key="className">IJKVideoViewController</string>
<string key="superclassName">UIViewController</string>
<dictionary class="NSMutableDictionary" key="actions">
<string key="onClickBack:">id</string>
<string key="onClickMediaControl:">id</string>
<string key="onClickOverlay:">id</string>
<string key="onClickPause:">id</string>
<string key="onClickPlay:">id</string>
</dictionary>
<dictionary class="NSMutableDictionary" key="actionInfosByName">
<object class="IBActionInfo" key="onClickBack:">
<string key="name">onClickBack:</string>
<string key="candidateClassName">id</string>
</object>
<object class="IBActionInfo" key="onClickMediaControl:">
<string key="name">onClickMediaControl:</string>
<string key="candidateClassName">id</string>
</object>
<object class="IBActionInfo" key="onClickOverlay:">
<string key="name">onClickOverlay:</string>
<string key="candidateClassName">id</string>
</object>
<object class="IBActionInfo" key="onClickPause:">
<string key="name">onClickPause:</string>
<string key="candidateClassName">id</string>
</object>
<object class="IBActionInfo" key="onClickPlay:">
<string key="name">onClickPlay:</string>
<string key="candidateClassName">id</string>
</object>
</dictionary>
<object class="NSMutableDictionary" key="outlets">
<string key="NS.key.0">mediaControl</string>
<string key="NS.object.0">IJKMediaControl</string>
</object>
<object class="NSMutableDictionary" key="toOneOutletInfosByName">
<string key="NS.key.0">mediaControl</string>
<object class="IBToOneOutletInfo" key="NS.object.0">
<string key="name">mediaControl</string>
<string key="candidateClassName">IJKMediaControl</string>
</object>
</object>
<object class="IBClassDescriptionSource" key="sourceIdentifier">
<string key="majorKey">IBProjectSource</string>
<string key="minorKey">./Classes/IJKVideoViewController.h</string>
</object>
</object>
</array>
</object>
<object class="IBClassDescriber" key="IBDocument.Classes"/>
<int key="IBDocument.localizationMode">0</int>
<string key="IBDocument.TargetRuntimeIdentifier">IBCocoaTouchFramework</string>
<bool key="IBDocument.PluginDeclaredDependenciesTrackSystemTargetVersion">YES</bool>
......
......@@ -7,6 +7,10 @@
objects = {
/* Begin PBXBuildFile section */
E63FC26917EFF39E003551EB /* ijksdl_aout_ios_audiounit.m in Sources */ = {isa = PBXBuildFile; fileRef = E63FC26817EFF39E003551EB /* ijksdl_aout_ios_audiounit.m */; settings = {COMPILER_FLAGS = "-fno-objc-arc"; }; };
E63FC26F17EFF79F003551EB /* IJKSDLAudioUnitController.m in Sources */ = {isa = PBXBuildFile; fileRef = E63FC26E17EFF79F003551EB /* IJKSDLAudioUnitController.m */; };
E63FC27117F01143003551EB /* ijksdl_audio.c in Sources */ = {isa = PBXBuildFile; fileRef = E63FC27017F01143003551EB /* ijksdl_audio.c */; };
E63FC27617F013DE003551EB /* ijksdl_vout_dummy.c in Sources */ = {isa = PBXBuildFile; fileRef = E63FC27417F013DE003551EB /* ijksdl_vout_dummy.c */; };
E66F8DC117EEC65200354D80 /* IJKMPMoviePlayerController.m in Sources */ = {isa = PBXBuildFile; fileRef = E66F8DC017EEC65200354D80 /* IJKMPMoviePlayerController.m */; };
E66F8DE717EFD9C300354D80 /* IJKFFPlayerController.m in Sources */ = {isa = PBXBuildFile; fileRef = E66F8DE617EFD9C300354D80 /* IJKFFPlayerController.m */; };
E66F8DF117EFEA9400354D80 /* ijkplayer.c in Sources */ = {isa = PBXBuildFile; fileRef = E66F8DEF17EFEA9400354D80 /* ijkplayer.c */; };
......@@ -45,6 +49,14 @@
/* End PBXCopyFilesBuildPhase section */
/* Begin PBXFileReference section */
E63FC26717EFF38C003551EB /* ijksdl_aout_ios_audiounit.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = ijksdl_aout_ios_audiounit.h; path = ijkmedia/ijksdl/ios/ijksdl_aout_ios_audiounit.h; sourceTree = "<group>"; };
E63FC26817EFF39E003551EB /* ijksdl_aout_ios_audiounit.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = ijksdl_aout_ios_audiounit.m; path = ijkmedia/ijksdl/ios/ijksdl_aout_ios_audiounit.m; sourceTree = "<group>"; };
E63FC26D17EFF79F003551EB /* IJKSDLAudioUnitController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = IJKSDLAudioUnitController.h; path = ijkmedia/ijksdl/ios/IJKSDLAudioUnitController.h; sourceTree = "<group>"; };
E63FC26E17EFF79F003551EB /* IJKSDLAudioUnitController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = IJKSDLAudioUnitController.m; path = ijkmedia/ijksdl/ios/IJKSDLAudioUnitController.m; sourceTree = "<group>"; };
E63FC27017F01143003551EB /* ijksdl_audio.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = ijksdl_audio.c; sourceTree = "<group>"; };
E63FC27317F013DE003551EB /* ijksdl_dummy.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ijksdl_dummy.h; sourceTree = "<group>"; };
E63FC27417F013DE003551EB /* ijksdl_vout_dummy.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = ijksdl_vout_dummy.c; sourceTree = "<group>"; };
E63FC27517F013DE003551EB /* ijksdl_vout_dummy.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ijksdl_vout_dummy.h; sourceTree = "<group>"; };
E66F8DBF17EEC65200354D80 /* IJKMPMoviePlayerController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = IJKMPMoviePlayerController.h; path = IJKMediaPlayer/IJKMPMoviePlayerController.h; sourceTree = "<group>"; };
E66F8DC017EEC65200354D80 /* IJKMPMoviePlayerController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = IJKMPMoviePlayerController.m; path = IJKMediaPlayer/IJKMPMoviePlayerController.m; sourceTree = "<group>"; };
E66F8DC217EECB1E00354D80 /* IJKMediaPlayer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = IJKMediaPlayer.h; path = IJKMediaPlayer/IJKMediaPlayer.h; sourceTree = "<group>"; };
......@@ -193,6 +205,16 @@
/* End PBXFrameworksBuildPhase section */
/* Begin PBXGroup section */
E63FC27217F013DE003551EB /* dummy */ = {
isa = PBXGroup;
children = (
E63FC27317F013DE003551EB /* ijksdl_dummy.h */,
E63FC27417F013DE003551EB /* ijksdl_vout_dummy.c */,
E63FC27517F013DE003551EB /* ijksdl_vout_dummy.h */,
);
path = dummy;
sourceTree = "<group>";
};
E66F8DBC17EEC2CF00354D80 /* Classes */ = {
isa = PBXGroup;
children = (
......@@ -235,6 +257,10 @@
isa = PBXGroup;
children = (
E66F8E0517EFEF3900354D80 /* ijksdl_ios.h */,
E63FC26717EFF38C003551EB /* ijksdl_aout_ios_audiounit.h */,
E63FC26817EFF39E003551EB /* ijksdl_aout_ios_audiounit.m */,
E63FC26D17EFF79F003551EB /* IJKSDLAudioUnitController.h */,
E63FC26E17EFF79F003551EB /* IJKSDLAudioUnitController.m */,
);
name = ios;
path = ../../ios/IJKMediaPlayer/IJKMediaPlayer;
......@@ -458,12 +484,14 @@
E6903FDF17EAFC6100CFD954 /* ijksdl */ = {
isa = PBXGroup;
children = (
E66F8DF917EFEC2100354D80 /* ios */,
E63FC27217F013DE003551EB /* dummy */,
E6903FEF17EAFC6100CFD954 /* ffmpeg */,
E66F8DF917EFEC2100354D80 /* ios */,
E6903FFD17EAFC6100CFD954 /* ijksdl.h */,
E6903FFF17EAFC6100CFD954 /* ijksdl_aout.c */,
E690400017EAFC6100CFD954 /* ijksdl_aout.h */,
E690400117EAFC6100CFD954 /* ijksdl_aout_internal.h */,
E63FC27017F01143003551EB /* ijksdl_audio.c */,
E690400217EAFC6100CFD954 /* ijksdl_audio.h */,
E690400317EAFC6100CFD954 /* ijksdl_endian.h */,
E690400417EAFC6100CFD954 /* ijksdl_error.c */,
......@@ -591,6 +619,10 @@
E66F8DE717EFD9C300354D80 /* IJKFFPlayerController.m in Sources */,
E66F8DF117EFEA9400354D80 /* ijkplayer.c in Sources */,
E66F8E0317EFEEA400354D80 /* ijkplayer_ios.c in Sources */,
E63FC26917EFF39E003551EB /* ijksdl_aout_ios_audiounit.m in Sources */,
E63FC26F17EFF79F003551EB /* IJKSDLAudioUnitController.m in Sources */,
E63FC27117F01143003551EB /* ijksdl_audio.c in Sources */,
E63FC27617F013DE003551EB /* ijksdl_vout_dummy.c in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
......
......@@ -7,9 +7,12 @@
//
#import "IJKFFPlayerController.h"
#include "ijkplayer/ios/ijkplayer_ios.h"
@implementation IJKFFPlayerController {
NSURL *_url;
IjkMediaPlayer *_mediaPlayer;
}
@synthesize view;
......@@ -24,13 +27,15 @@
self = [super init];
if (self) {
self->_url = aUrl;
self->_mediaPlayer = ijkmp_ios_create(media_player_msg_loop);
ijkmp_set_weak_thiz(self->_mediaPlayer, (__bridge_retained void *) self);
}
return self;
}
- (void)prepareToPlay
{
ijkmp_set_data_source(_mediaPlayer, [[self->_url absoluteString] UTF8String]);
}
- (void)play
......@@ -53,4 +58,29 @@
return NO;
}
- (void)postEvent: (AVMessage *)msg
{
}
void *media_player_msg_loop(void* arg)
{
IjkMediaPlayer *mp = (IjkMediaPlayer*)arg;
IJKFFPlayerController *ffpController = (__bridge_transfer IJKFFPlayerController *) ijkmp_set_weak_thiz(mp, NULL);
while (true) {
AVMessage msg;
int retval = ijkmp_get_msg(mp, &msg, 1);
if (retval < 0)
break;
// block-get should never return 0
assert(retval > 0);
[ffpController postEvent:&msg];
}
return NULL;
}
@end
......@@ -4,5 +4,10 @@
#ifdef __OBJC__
#import <Foundation/Foundation.h>
#import <MediaPlayer/MediaPlayer.h>
#import <AudioUnit/AudioUnit.h>
#import <CoreAudio/CoreAudioTypes.h>
#import <AudioToolbox/AudioToolbox.h>
#endif
......@@ -8,3 +8,4 @@
#import "IJKMediaPlayback.h"
#import "IJKMPMoviePlayerController.h"
#import "IJKFFPlayerController.h"
\ No newline at end of file
......@@ -26,6 +26,7 @@
#include <assert.h>
#include "ijksdl/ios/ijksdl_ios.h"
#include "ijksdl/dummy/ijksdl_dummy.h"
#include "ijkplayer/ff_fferror.h"
#include "ijkplayer/ff_ffplay.h"
#include "ijkplayer/ijkplayer_internal.h"
......@@ -36,15 +37,13 @@ IjkMediaPlayer *ijkmp_ios_create(void *(*msg_loop)(void*))
if (!mp)
goto fail;
/*-
mp->ffplayer->vout = SDL_VoutAndroid_CreateForAndroidSurface();
mp->ffplayer->vout = SDL_VoutDummy_Create();
if (!mp->ffplayer->vout)
goto fail;
mp->ffplayer->aout = SDL_AoutAndroid_CreateForAudioTrack();
mp->ffplayer->aout = SDL_AoutIos_CreateForAudioUnit();
if (!mp->ffplayer->vout)
goto fail;
*/
return mp;
......
......@@ -28,6 +28,4 @@
// ref_count is 1 after open
IjkMediaPlayer *ijkmp_ios_create(void *(*msg_loop)(void*));
void ijkmp_ios_set_surface(IjkMediaPlayer *mp);
#endif
......@@ -8,6 +8,19 @@
#import <Foundation/Foundation.h>
#include "ijksdl/ijksdl_aout.h"
@interface IJKSDLAudioUnitController : NSObject
- (id)initWithAudioSpec:(SDL_AudioSpec *)aSpec;
- (void)play;
- (void)pause;
- (void)flush;
- (void)stop;
- (void)close;
@property (nonatomic, readonly) SDL_AudioSpec spec;
@property (nonatomic, getter=isPaused) BOOL paused;
@end
......@@ -7,7 +7,197 @@
//
#import "IJKSDLAudioUnitController.h"
#include "ijkutil/ijkutil.h"
@implementation IJKSDLAudioUnitController
@implementation IJKSDLAudioUnitController {
AudioUnit _au_unit;
}
- (id)initWithAudioSpec:(SDL_AudioSpec *)aSpec
{
self = [super init];
if (self) {
if (aSpec == NULL) {
self = nil;
return nil;
}
self->_spec = *aSpec;
AudioComponentDescription desc;
desc.componentType = kAudioUnitType_Output;
desc.componentSubType = kAudioUnitSubType_RemoteIO;
desc.componentManufacturer = kAudioUnitManufacturer_Apple;
desc.componentFlags = 0;
desc.componentFlagsMask = 0;
AudioComponent au_component = AudioComponentFindNext(NULL, &desc);
if (au_component == NULL) {
ALOGE("AudioUnit: AudioComponentFindNext failed");
self = nil;
return nil;
}
AudioUnit au_unit;
OSStatus status = AudioComponentInstanceNew(au_component, &au_unit);
if (status != noErr) {
ALOGE("AudioUnit: AudioComponentInstanceNew failed");
self = nil;
return nil;
}
UInt32 flag = 1;
status = AudioUnitSetProperty(au_unit,
kAudioOutputUnitProperty_EnableIO,
kAudioUnitScope_Output,
0,
&flag,
sizeof(flag));
if (status != noErr) {
ALOGE("AudioUnit: failed to set IO mode (%li)", status);
}
/* Get the current format */
AudioStreamBasicDescription streamDescription;
streamDescription.mSampleRate = self->_spec.freq;
self->_spec.format = AUDIO_S16SYS;
streamDescription.mFormatID = kAudioFormatLinearPCM;
streamDescription.mFormatFlags = kLinearPCMFormatFlagIsPacked;
streamDescription.mChannelsPerFrame = self->_spec.channels;
streamDescription.mFramesPerPacket = 1;
streamDescription.mBitsPerChannel = SDL_AUDIO_BITSIZE(self->_spec.format);
if (SDL_AUDIO_ISBIGENDIAN(self->_spec.format))
streamDescription.mFormatFlags |= kLinearPCMFormatFlagIsBigEndian;
if (SDL_AUDIO_ISFLOAT(self->_spec.format))
streamDescription.mFormatFlags |= kLinearPCMFormatFlagIsFloat;
if (SDL_AUDIO_ISSIGNED(self->_spec.format))
streamDescription.mFormatFlags |= kLinearPCMFormatFlagIsSignedInteger;
streamDescription.mBytesPerFrame = streamDescription.mBitsPerChannel * streamDescription.mChannelsPerFrame / 8;
streamDescription.mBytesPerPacket = streamDescription.mBytesPerFrame * streamDescription.mFramesPerPacket;
/* Set the desired format */
UInt32 i_param_size = sizeof(streamDescription);
status = AudioUnitSetProperty(au_unit,
kAudioUnitProperty_StreamFormat,
kAudioUnitScope_Input,
0,
&streamDescription,
i_param_size);
if (status != noErr) {
ALOGE("AudioUnit: failed to set stream format (%li)", status);
self = nil;
return nil;
}
/* Retrieve actual format */
status = AudioUnitGetProperty(au_unit,
kAudioUnitProperty_StreamFormat,
kAudioUnitScope_Input,
0,
&streamDescription,
&i_param_size);
if (status != noErr) {
ALOGE("AudioUnit: failed to verify stream format (%li)", status);
}
AURenderCallbackStruct callback;
callback.inputProc = (AURenderCallback) RenderCallback;
callback.inputProcRefCon = (__bridge_retained void*) self;
status = AudioUnitSetProperty(au_unit,
kAudioUnitProperty_SetRenderCallback,
kAudioUnitScope_Input,
0, &callback, sizeof(callback));
if (status != noErr) {
ALOGE("AudioUnit: render callback setup failed (%li)", status);
self = nil;
return nil;
}
SDL_CalculateAudioSpec(&self->_spec);
/* AU initiliaze */
status = AudioUnitInitialize(au_unit);
if (status != noErr) {
ALOGE("AudioUnit: AudioUnitInitialize failed (%li)", status);
self = nil;
return nil;
}
/* start audio session so playback continues if mute switch is on */
AudioSessionInitialize (NULL,
kCFRunLoopCommonModes,
NULL,
NULL);
/* Set audio session to mediaplayback */
UInt32 sessionCategory = kAudioSessionCategory_MediaPlayback;
AudioSessionSetProperty(kAudioSessionProperty_AudioCategory, sizeof(sessionCategory), &sessionCategory);
AudioSessionSetActive(true);
self->_au_unit = au_unit;
}
return self;
}
- (void)play
{
AudioOutputUnitStart(self->_au_unit);
AudioSessionSetActive(true);
}
- (void)pause
{
AudioOutputUnitStop(self->_au_unit);
AudioSessionSetActive(false);
}
- (void)flush
{
AudioOutputUnitStop(self->_au_unit);
}
- (void)stop
{
AudioSessionSetActive(false);
OSStatus status = AudioOutputUnitStop(self->_au_unit);
if (status != noErr)
ALOGE("AudioUnit: failed to stop AudioUnit (%li)", status);
status = AudioComponentInstanceDispose(self->_au_unit);
if (status != noErr)
ALOGE("AudioUnit: failed to dispose Audio Component instance (%li)", status);
}
- (void)close
{
[self stop];
}
static OSStatus RenderCallback(void *inRefCon,
AudioUnitRenderActionFlags *ioActionFlags,
const AudioTimeStamp *inTimeStamp,
UInt32 inBusNumber,
UInt32 inNumberFrames,
AudioBufferList *ioData)
{
IJKSDLAudioUnitController* auController = (__bridge_transfer IJKSDLAudioUnitController*) inRefCon;
if (!auController.paused) {
for (UInt32 i = 0; i < ioData->mNumberBuffers; i++) {
AudioBuffer *ioBuffer = &ioData->mBuffers[i];
memset(ioBuffer->mData, auController.spec.silence, ioBuffer->mDataByteSize);
}
return noErr;
}
for (UInt32 i = 0; i < ioData->mNumberBuffers; i++) {
AudioBuffer *ioBuffer = &ioData->mBuffers[i];
(*auController.spec.callback)(auController.spec.userdata, ioBuffer->mData, ioBuffer->mDataByteSize);
}
return noErr;
}
@end
//
// ijksdl_aout_ios_audiocomponent.h
// IJKMediaPlayer
//
// Created by ZhangRui on 13-9-23.
// Copyright (c) 2013年 bilibili. All rights reserved.
//
/*
* ijksdl_aout_ios_audiounit.h
*
* Copyright (c) 2013 Zhang Rui <bbcallen@gmail.com>
*
* This file is part of ijkPlayer.
*
* ijkPlayer is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* ijkPlayer is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with ijkPlayer; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#ifndef IJKMediaPlayer_ijksdl_aout_ios_audiocomponent_h
#define IJKMediaPlayer_ijksdl_aout_ios_audiocomponent_h
#ifndef IJKMediaPlayer_ijksdl_aout_ios_audiounit_h
#define IJKMediaPlayer_ijksdl_aout_ios_audiounit_h
#include "ijksdl/ijksdl_aout.h"
SDL_Aout *SDL_AoutIos_CreateForAudioUnit();
#endif
//
// ijksdl_aout_ios_audiocomponent.c
// IJKMediaPlayer
//
// Created by ZhangRui on 13-9-23.
// Copyright (c) 2013年 bilibili. All rights reserved.
//
#include <stdio.h>
/*
* ijksdl_aout_ios_audiounit.m
*
* Copyright (c) 2013 Zhang Rui <bbcallen@gmail.com>
*
* This file is part of ijkPlayer.
*
* ijkPlayer is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* ijkPlayer is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with ijkPlayer; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include "ijksdl_aout_ios_audiounit.h"
#include <stdbool.h>
#include <assert.h>
#include "ijksdl/ijksdl_inc_internal.h"
#include "ijksdl/ijksdl_thread.h"
#include "ijksdl/ijksdl_aout_internal.h"
#import "IJKSDLAudioUnitController.h"
typedef struct SDL_Aout_Opaque {
SDL_AudioSpec spec;
IJKSDLAudioUnitController *auController;
} SDL_Aout_Opaque;
int aout_open_audio(SDL_Aout *aout, SDL_AudioSpec *desired, SDL_AudioSpec *obtained)
{
assert(desired);
SDLTRACE("aout_open_audio()");
SDL_Aout_Opaque *opaque = aout->opaque;
opaque->auController = [[[IJKSDLAudioUnitController alloc] initWithAudioSpec:desired] retain];
if (!opaque->auController) {
ALOGE("aout_open_audio_n: failed to new AudioTrcak()");
return -1;
}
opaque->spec = opaque->auController.spec;
return 0;
}
void aout_pause_audio(SDL_Aout *aout, int pause_on)
{
SDLTRACE("aout_pause_audio()");
SDL_Aout_Opaque *opaque = aout->opaque;
if (pause_on) {
[opaque->auController pause];
} else {
[opaque->auController play];
}
}
void aout_flush_audio(SDL_Aout *aout)
{
SDLTRACE("aout_flush_audio()");
SDL_Aout_Opaque *opaque = aout->opaque;
[opaque->auController flush];
}
void aout_close_audio(SDL_Aout *aout)
{
SDLTRACE("aout_flush_audio()");
SDL_Aout_Opaque *opaque = aout->opaque;
[opaque->auController close];
}
void aout_free_l(SDL_Aout *aout)
{
if (!aout)
return;
aout_close_audio(aout);
SDL_Aout_Opaque *opaque = aout->opaque;
if (opaque) {
[opaque->auController release];
opaque->auController = nil;
}
SDL_Aout_FreeInternal(aout);
}
SDL_Aout *SDL_AoutIos_CreateForAudioUnit()
{
SDL_Aout *aout = SDL_Aout_CreateInternal(sizeof(SDL_Aout_Opaque));
if (!aout)
return NULL;
// SDL_Aout_Opaque *opaque = aout->opaque;
aout->free_l = aout_free_l;
aout->open_audio = aout_open_audio;
aout->pause_audio = aout_pause_audio;
aout->flush_audio = aout_flush_audio;
aout->close_audio = aout_close_audio;
return aout;
}
......@@ -25,7 +25,7 @@
#include "ijksdl/ijksdl.h"
// #include "ijksdl_aout_android_audiotrack.h"
#include "ijksdl_aout_ios_audiounit.h"
// #include "ijksdl_vout_android_nativewindow.h"
// #include "ijksdl_vout_android_surface.h"
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册