提交 02f5d979 编写于 作者: X Xinzheng Zhang

videotoolbox: abstract videotoolbox interface

duplicate ijkvideotoolbox to vtb_async and vtb_sync
上级 6646513d
......@@ -7,6 +7,10 @@
objects = {
/* Begin PBXBuildFile section */
5407EC291DF7F93B00457BFE /* IJKVideoToolBox.h in Headers */ = {isa = PBXBuildFile; fileRef = 5407EC271DF7F93B00457BFE /* IJKVideoToolBox.h */; };
5407EC2A1DF7F93B00457BFE /* IJKVideoToolBox.m in Sources */ = {isa = PBXBuildFile; fileRef = 5407EC281DF7F93B00457BFE /* IJKVideoToolBox.m */; };
5407EC2D1DF81D2600457BFE /* IJKVideoToolBoxSync.h in Headers */ = {isa = PBXBuildFile; fileRef = 5407EC2B1DF81D2600457BFE /* IJKVideoToolBoxSync.h */; };
5407EC2E1DF81D2600457BFE /* IJKVideoToolBoxSync.m in Sources */ = {isa = PBXBuildFile; fileRef = 5407EC2C1DF81D2600457BFE /* IJKVideoToolBoxSync.m */; };
54A029B61D4700E6001C61C1 /* ijkasync.c in Sources */ = {isa = PBXBuildFile; fileRef = 54A029B11D4700E6001C61C1 /* ijkasync.c */; };
54A029B71D4700E6001C61C1 /* ijkavformat.h in Headers */ = {isa = PBXBuildFile; fileRef = 54A029B21D4700E6001C61C1 /* ijkavformat.h */; };
54A029B81D4700E6001C61C1 /* ijklongurl.c in Sources */ = {isa = PBXBuildFile; fileRef = 54A029B31D4700E6001C61C1 /* ijklongurl.c */; };
......@@ -41,7 +45,7 @@
E654EAB41B6B285900B0F2D0 /* ijkplayer.c in Sources */ = {isa = PBXBuildFile; fileRef = E66F8DEF17EFEA9400354D80 /* ijkplayer.c */; };
E654EAB51B6B286400B0F2D0 /* ffpipeline_ios.c in Sources */ = {isa = PBXBuildFile; fileRef = 454316201A66493700676070 /* ffpipeline_ios.c */; };
E654EAB61B6B286400B0F2D0 /* ffpipenode_ios_videotoolbox_vdec.m in Sources */ = {isa = PBXBuildFile; fileRef = 454316231A66493700676070 /* ffpipenode_ios_videotoolbox_vdec.m */; };
E654EAB81B6B286400B0F2D0 /* IJKVideoToolBox.m in Sources */ = {isa = PBXBuildFile; fileRef = 4543162A1A66497900676070 /* IJKVideoToolBox.m */; };
E654EAB81B6B286400B0F2D0 /* IJKVideoToolBoxAsync.m in Sources */ = {isa = PBXBuildFile; fileRef = 4543162A1A66497900676070 /* IJKVideoToolBoxAsync.m */; };
E654EAB91B6B286700B0F2D0 /* ijkplayer_ios.m in Sources */ = {isa = PBXBuildFile; fileRef = E66F8E0117EFEEA400354D80 /* ijkplayer_ios.m */; settings = {COMPILER_FLAGS = "-fno-objc-arc"; }; };
E654EABA1B6B286B00B0F2D0 /* ffpipeline_ffplay.c in Sources */ = {isa = PBXBuildFile; fileRef = E67B91B21A3801E600717EA9 /* ffpipeline_ffplay.c */; };
E654EABB1B6B286B00B0F2D0 /* ffpipenode_ffplay_vdec.c in Sources */ = {isa = PBXBuildFile; fileRef = E67B91B41A3801E600717EA9 /* ffpipenode_ffplay_vdec.c */; };
......@@ -121,10 +125,14 @@
454316211A66493700676070 /* ffpipeline_ios.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = ffpipeline_ios.h; path = ijkmedia/ijkplayer/ios/pipeline/ffpipeline_ios.h; sourceTree = "<group>"; };
454316221A66493700676070 /* ffpipenode_ios_videotoolbox_vdec.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = ffpipenode_ios_videotoolbox_vdec.h; path = ijkmedia/ijkplayer/ios/pipeline/ffpipenode_ios_videotoolbox_vdec.h; sourceTree = "<group>"; };
454316231A66493700676070 /* ffpipenode_ios_videotoolbox_vdec.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = ffpipenode_ios_videotoolbox_vdec.m; path = ijkmedia/ijkplayer/ios/pipeline/ffpipenode_ios_videotoolbox_vdec.m; sourceTree = "<group>"; };
454316291A66497900676070 /* IJKVideoToolBox.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = IJKVideoToolBox.h; path = ijkmedia/ijkplayer/ios/pipeline/IJKVideoToolBox.h; sourceTree = "<group>"; };
4543162A1A66497900676070 /* IJKVideoToolBox.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = IJKVideoToolBox.m; path = ijkmedia/ijkplayer/ios/pipeline/IJKVideoToolBox.m; sourceTree = "<group>"; };
454316291A66497900676070 /* IJKVideoToolBoxAsync.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = IJKVideoToolBoxAsync.h; path = ijkmedia/ijkplayer/ios/pipeline/IJKVideoToolBoxAsync.h; sourceTree = "<group>"; };
4543162A1A66497900676070 /* IJKVideoToolBoxAsync.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = IJKVideoToolBoxAsync.m; path = ijkmedia/ijkplayer/ios/pipeline/IJKVideoToolBoxAsync.m; sourceTree = "<group>"; };
45DB4AA71A5D52AE005CAD41 /* ijksdl_vout_overlay_videotoolbox.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ijksdl_vout_overlay_videotoolbox.h; sourceTree = "<group>"; };
45DB4AA81A5D52AE005CAD41 /* ijksdl_vout_overlay_videotoolbox.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ijksdl_vout_overlay_videotoolbox.m; sourceTree = "<group>"; };
5407EC271DF7F93B00457BFE /* IJKVideoToolBox.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = IJKVideoToolBox.h; path = ijkmedia/ijkplayer/ios/pipeline/IJKVideoToolBox.h; sourceTree = "<group>"; };
5407EC281DF7F93B00457BFE /* IJKVideoToolBox.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = IJKVideoToolBox.m; path = ijkmedia/ijkplayer/ios/pipeline/IJKVideoToolBox.m; sourceTree = "<group>"; };
5407EC2B1DF81D2600457BFE /* IJKVideoToolBoxSync.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = IJKVideoToolBoxSync.h; path = ijkmedia/ijkplayer/ios/pipeline/IJKVideoToolBoxSync.h; sourceTree = "<group>"; };
5407EC2C1DF81D2600457BFE /* IJKVideoToolBoxSync.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = IJKVideoToolBoxSync.m; path = ijkmedia/ijkplayer/ios/pipeline/IJKVideoToolBoxSync.m; sourceTree = "<group>"; };
54A029B11D4700E6001C61C1 /* ijkasync.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = ijkasync.c; sourceTree = "<group>"; };
54A029B21D4700E6001C61C1 /* ijkavformat.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ijkavformat.h; sourceTree = "<group>"; };
54A029B31D4700E6001C61C1 /* ijklongurl.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = ijklongurl.c; sourceTree = "<group>"; };
......@@ -311,8 +319,12 @@
454316221A66493700676070 /* ffpipenode_ios_videotoolbox_vdec.h */,
454316231A66493700676070 /* ffpipenode_ios_videotoolbox_vdec.m */,
E6D5FFF71B5F445E00E1E328 /* h264_sps_parser.h */,
454316291A66497900676070 /* IJKVideoToolBox.h */,
4543162A1A66497900676070 /* IJKVideoToolBox.m */,
5407EC271DF7F93B00457BFE /* IJKVideoToolBox.h */,
5407EC281DF7F93B00457BFE /* IJKVideoToolBox.m */,
454316291A66497900676070 /* IJKVideoToolBoxAsync.h */,
4543162A1A66497900676070 /* IJKVideoToolBoxAsync.m */,
5407EC2B1DF81D2600457BFE /* IJKVideoToolBoxSync.h */,
5407EC2C1DF81D2600457BFE /* IJKVideoToolBoxSync.m */,
);
name = pipeline;
sourceTree = "<group>";
......@@ -728,9 +740,11 @@
E654EAE71B6B295200B0F2D0 /* IJKMediaPlayback.h in Headers */,
E654EAED1B6B29C100B0F2D0 /* IJKMediaPlayer.h in Headers */,
E6C459961C7030B6004831EC /* internal.h in Headers */,
5407EC2D1DF81D2600457BFE /* IJKVideoToolBoxSync.h in Headers */,
E654EAE91B6B295200B0F2D0 /* IJKMPMoviePlayerController.h in Headers */,
54A029B71D4700E6001C61C1 /* ijkavformat.h in Headers */,
E68B7ACF1C1E97B0001DE241 /* IJKSDLHudViewCell.h in Headers */,
5407EC291DF7F93B00457BFE /* IJKVideoToolBox.h in Headers */,
E698089B1C7EB13A0048A46C /* NSString+IJKMedia.h in Headers */,
);
runOnlyForDeploymentPostprocessing = 0;
......@@ -871,12 +885,14 @@
E654EACB1B6B288A00B0F2D0 /* ijksdl_vout_overlay_videotoolbox.m in Sources */,
E654EAB11B6B285900B0F2D0 /* ff_ffpipenode.c in Sources */,
E654EAC41B6B287E00B0F2D0 /* ijksdl_stdinc.c in Sources */,
5407EC2A1DF7F93B00457BFE /* IJKVideoToolBox.m in Sources */,
54A029B91D4700E6001C61C1 /* ijksegment.c in Sources */,
E654EAA61B6B283700B0F2D0 /* IJKMediaUtils.m in Sources */,
E6C459931C7030B6004831EC /* common.c in Sources */,
E654EAC81B6B288A00B0F2D0 /* ijksdl_aout_ios_audiounit.m in Sources */,
E69BE5721B946FF600AFBA3F /* ijklivehook.c in Sources */,
54A029BA1D4700E6001C61C1 /* ijkurlhook.c in Sources */,
5407EC2E1DF81D2600457BFE /* IJKVideoToolBoxSync.m in Sources */,
E654EAA51B6B283700B0F2D0 /* IJKMediaPlayback.m in Sources */,
E654EAB01B6B285900B0F2D0 /* ff_ffpipeline.c in Sources */,
E654EACC1B6B288A00B0F2D0 /* IJKSDLAudioKit.m in Sources */,
......@@ -907,7 +923,7 @@
E69808A11C7EB2040048A46C /* IJKNotificationManager.m in Sources */,
E654EAA41B6B283700B0F2D0 /* IJKMediaModule.m in Sources */,
E654EAAF1B6B285900B0F2D0 /* ff_cmdutils.c in Sources */,
E654EAB81B6B286400B0F2D0 /* IJKVideoToolBox.m in Sources */,
E654EAB81B6B286400B0F2D0 /* IJKVideoToolBoxAsync.m in Sources */,
E6C459991C7030B6004831EC /* renderer_yuv444p10le.c in Sources */,
E654EABE1B6B287400B0F2D0 /* image_convert.c in Sources */,
E6C459C41C708E60004831EC /* rgb.fsh.c in Sources */,
......
......@@ -21,27 +21,23 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#ifndef IJKMediaPlayer_videotoolbox_core_h
#define IJKMediaPlayer_videotoolbox_core_h
#ifndef IJKMediaPlayer_videotoolbox_h
#define IJKMediaPlayer_videotoolbox_h
#import <VideoToolbox/VideoToolbox.h>
#include "ff_ffinc.h"
#include "ff_fferror.h"
#include "ff_ffmsg.h"
#include "ff_ffplay.h"
#include "ijksdl/ios/ijksdl_vout_overlay_videotoolbox.h"
#define MAX_PKT_QUEUE_DEEP 350
#define VTB_MAX_DECODING_SAMPLES 3
typedef struct Ijk_VideoToolBox_Opaque Ijk_VideoToolBox_Opaque;
typedef struct Ijk_VideoToolBox Ijk_VideoToolBox;
typedef struct VideoToolBoxContext VideoToolBoxContext;
struct Ijk_VideoToolBox {
VideoToolBoxContext* videotoolbox_create(FFPlayer* ffp, AVCodecContext* ic);
Ijk_VideoToolBox_Opaque *opaque;
int videotoolbox_decode_frame(VideoToolBoxContext* context);
int (*decode_frame)(Ijk_VideoToolBox_Opaque *opaque);
void (*free)(Ijk_VideoToolBox_Opaque *opaque);
};
void videotoolbox_free(VideoToolBoxContext* context);
Ijk_VideoToolBox *Ijk_VideoToolbox_Async_Create(FFPlayer* ffp, AVCodecContext* ic);
Ijk_VideoToolBox *Ijk_VideoToolbox_Sync_Create(FFPlayer* ffp, AVCodecContext* ic);
#endif
/*****************************************************************************
* IJKVideoToolBox.h
*****************************************************************************
*
* copyright (c) 2014 Zhou Quan <zhouqicy@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_videotoolbox_async_h
#define IJKMediaPlayer_videotoolbox_async_h
#include "ff_ffplay.h"
typedef struct Ijk_VideoToolBox_Opaque Ijk_VideoToolBox_Opaque;
Ijk_VideoToolBox_Opaque* videotoolbox_async_create(FFPlayer* ffp, AVCodecContext* ic);
int videotoolbox_async_decode_frame(Ijk_VideoToolBox_Opaque* opaque);
void videotoolbox_async_free(Ijk_VideoToolBox_Opaque* opaque);
#endif
/*****************************************************************************
* IJKVideoToolBox.h
*****************************************************************************
*
* copyright (c) 2014 Zhou Quan <zhouqicy@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_videotoolbox_sync_h
#define IJKMediaPlayer_videotoolbox_sync_h
#include "ff_ffplay.h"
typedef struct Ijk_VideoToolBox_Opaque Ijk_VideoToolBox_Opaque;
Ijk_VideoToolBox_Opaque* videotoolbox_sync_create(FFPlayer* ffp, AVCodecContext* ic);
int videotoolbox_sync_decode_frame(Ijk_VideoToolBox_Opaque* opaque);
void videotoolbox_sync_free(Ijk_VideoToolBox_Opaque* opaque);
#endif
......@@ -34,7 +34,7 @@ struct IJKFF_Pipenode_Opaque {
IJKFF_Pipeline *pipeline;
FFPlayer *ffp;
Decoder *decoder;
VideoToolBoxContext *context;
Ijk_VideoToolBox *context;
AVCodecContext *avctx; // not own
SDL_Thread* video_fill_thread;
SDL_Thread _video_fill_thread;
......@@ -54,7 +54,7 @@ int videotoolbox_video_thread(void *arg)
return -1;
}
@autoreleasepool {
ret = videotoolbox_decode_frame(opaque->context);
ret = opaque->context->decode_frame(opaque->context->opaque);
}
if (ret < 0)
goto the_end;
......@@ -81,7 +81,7 @@ static int func_run_sync(IJKFF_Pipenode *node)
int ret = videotoolbox_video_thread(opaque);
if (opaque->context) {
videotoolbox_free(opaque->context);
opaque->context->free(opaque->context->opaque);
free(opaque->context);
opaque->context = NULL;
}
......@@ -112,7 +112,10 @@ IJKFF_Pipenode *ffpipenode_create_video_decoder_from_ios_videotoolbox(FFPlayer *
opaque->avctx = opaque->decoder->avctx;
switch (opaque->avctx->codec_id) {
case AV_CODEC_ID_H264:
opaque->context = videotoolbox_create(ffp, opaque->avctx);
if (ffp->vtb_async)
opaque->context = Ijk_VideoToolbox_Async_Create(ffp, opaque->avctx);
else
opaque->context = Ijk_VideoToolbox_Sync_Create(ffp, opaque->avctx);
break;
default:
ALOGI("Videotoolbox-pipeline:open_video_decoder: not H264\n");
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册