Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/objective-c/23.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Objective c 视频播放镜像预防解决方案 环境 Xcode@OS-X约塞米蒂 iOS应用程序@Obj-C 用例 在iOS和OSX()之间设置Quicktime镜像会话 第三方SDK与iOS应用程序集成 SDK用于视频播放 播放视频且镜像会话已设置(作为外部显示器)时,不播放视频(仅音频) SDK没有任何API来控制镜像时打开/关闭外部视频播放/镜像_Objective C_Ios8_Avfoundation_Swizzling_Video Toolbox - Fatal编程技术网

Objective c 视频播放镜像预防解决方案 环境 Xcode@OS-X约塞米蒂 iOS应用程序@Obj-C 用例 在iOS和OSX()之间设置Quicktime镜像会话 第三方SDK与iOS应用程序集成 SDK用于视频播放 播放视频且镜像会话已设置(作为外部显示器)时,不播放视频(仅音频) SDK没有任何API来控制镜像时打开/关闭外部视频播放/镜像

Objective c 视频播放镜像预防解决方案 环境 Xcode@OS-X约塞米蒂 iOS应用程序@Obj-C 用例 在iOS和OSX()之间设置Quicktime镜像会话 第三方SDK与iOS应用程序集成 SDK用于视频播放 播放视频且镜像会话已设置(作为外部显示器)时,不播放视频(仅音频) SDK没有任何API来控制镜像时打开/关闭外部视频播放/镜像,objective-c,ios8,avfoundation,swizzling,video-toolbox,Objective C,Ios8,Avfoundation,Swizzling,Video Toolbox,我需要能够将视频镜像到我的OSX桌面,为此,我已尝试通过以下方式对第三方SDK隐藏镜像屏幕(但没有帮助): 如何绕过视频播放镜像保护?我是否应该拦截任何较低级别的API namespace NSNotificationCenterS { namespace Original { IMP addObserver = 0; } void addObserver(id self, SEL _cmd, id notificationObserver, S

我需要能够将视频镜像到我的OSX桌面,为此,我已尝试通过以下方式对第三方SDK隐藏镜像屏幕(但没有帮助):

如何绕过视频播放镜像保护?我是否应该拦截任何较低级别的API

namespace NSNotificationCenterS
{
    namespace Original
    {
        IMP addObserver = 0;
    }

    void addObserver(id self, SEL _cmd, id notificationObserver, SEL notificationSelector, NSString* notificationName, id notificationSender){
        if( (YES == [notificationName isEqualToString:UIScreenDidConnectNotification]) || 
            (YES == [notificationName isEqualToString:UIScreenDidDisconnectNotification]) || 
            (YES == [notificationName isEqualToString:UIScreenModeDidChangeNotification ]) ) 
        {
            NSLog(@"NSNotificationCenter addObserver(%@, %@, '%@', %@) SUPRESSED!!!", notificationObserver, NSStringFromSelector(notificationSelector), notificationName, notificationSender);
            return;// Supress notifications of this kind of events 
        }
        // NSLog(@"NSNotificationCenter addObserver(%@, %@, '%@', %@)", notificationObserver, NSStringFromSelector(notificationSelector), notificationName, notificationSender);
        ((void(*)(id, SEL, id, SEL, NSString*,id))Original::addObserver)(self, _cmd, notificationObserver, notificationSelector, notificationName, notificationSender);
    }

    void initHooks() {
        Method method;
        method = class_getInstanceMethod([NSNotificationCenter class], @selector(addObserver:selector:name:object:));
        Original::addObserver = method_getImplementation(method);
        method_setImplementation(method, (IMP)NSNotificationCenterS::addObserver);
    }
}

namespace AVPlayerS
{
    namespace Original
    {
        IMP init = 0;
        IMP setAllowsExternalPlayback = 0;
        IMP setUsesExternalPlaybackWhileExternalScreenIsActive = 0;
        IMP setAllowsAirPlayVideo = 0;
        IMP setUsesAirPlayVideoWhileAirPlayScreenIsActive = 0;
    }

    id init(id self, SEL _cmd) {
        NSLog(@"AVPlayer init, %@\n", self);
        id ret = ((id(*)(id,SEL))Original::init)(self, _cmd);
        if(nil == ret)
            return nil;
        ((void(*)(id, SEL, BOOL))Original::setAllowsExternalPlayback)(ret, @selector(setAllowsExternalPlayback:), YES);
        ((void(*)(id, SEL, BOOL))Original::setUsesExternalPlaybackWhileExternalScreenIsActive)(ret, @selector(setUsesExternalPlaybackWhileExternalScreenIsActive:), YES);
        ((void(*)(id, SEL, BOOL))Original::setAllowsAirPlayVideo)(ret, @selector(setAllowsAirPlayVideo:), YES);
        ((void(*)(id, SEL, BOOL))Original::setUsesAirPlayVideoWhileAirPlayScreenIsActive)(ret, @selector(setUsesAirPlayVideoWhileAirPlayScreenIsActive:), YES);

        NSLog(@"AVPlayer, %d, %d, %d, %d\n", [ret allowsExternalPlayback], [ret usesExternalPlaybackWhileExternalScreenIsActive], [ret allowsAirPlayVideo], [ret usesAirPlayVideoWhileAirPlayScreenIsActive]);
        return ret;
    }

    UIScreen* mirroredScreen(id self, SEL _cmd) {
        return nil;
    }

    NSArray* getScreens(id self, SEL _cmd) {
        return [NSArray arrayWithObject:[UIScreen mainScreen]];
    }

    void flag_stub(id self, SEL _cmd, BOOL bSet){
        NSLog(@"AVPlayer flag_stub(%@, %@, '%s')", self, NSStringFromSelector(_cmd), bSet ? "true" : "false");
    }

    BOOL ret_YES(id self, SEL _cmd) {
        NSLog(@"AVPlayer ret_YES(%@, %@)", self, NSStringFromSelector(_cmd));
        return YES;
    }

    BOOL ret_NO(id self, SEL _cmd) {
        NSLog(@"AVPlayer ret_NO(%@, %@)", self, NSStringFromSelector(_cmd));
        return NO;
    }

    void initHooks() {
        Method method;

        method   = class_getInstanceMethod([UIScreen class], @selector(mirroredScreen));
        method_setImplementation(method, (IMP)AVPlayerS::mirroredScreen);

        method   = class_getClassMethod([UIScreen class], @selector(screens));
        method_setImplementation(method, (IMP)AVPlayerS::getScreens);

        method = class_getInstanceMethod([AVPlayer class], @selector(init));
        AVPlayerS::Original::init  = method_getImplementation(method);
        method_setImplementation(method, (IMP)AVPlayerS::init);

        method = class_getInstanceMethod([AVPlayer class], @selector(setAllowsExternalPlayback:));
        AVPlayerS::Original::setAllowsExternalPlayback  = method_getImplementation(method);
        method_setImplementation(method, (IMP)flag_stub);

        method = class_getInstanceMethod([AVPlayer class], @selector(setUsesExternalPlaybackWhileExternalScreenIsActive:));
        AVPlayerS::Original::setUsesExternalPlaybackWhileExternalScreenIsActive  = method_getImplementation(method);
        method_setImplementation(method, (IMP)flag_stub);

        method = class_getInstanceMethod([AVPlayer class], @selector(setAllowsAirPlayVideo:));
        AVPlayerS::Original::setAllowsAirPlayVideo  = method_getImplementation(method);
        method_setImplementation(method, (IMP)flag_stub);

        method = class_getInstanceMethod([AVPlayer class], @selector(setUsesAirPlayVideoWhileAirPlayScreenIsActive:));
        AVPlayerS::Original::setUsesAirPlayVideoWhileAirPlayScreenIsActive  = method_getImplementation(method);
        method_setImplementation(method, (IMP)flag_stub);

        method = class_getInstanceMethod([AVPlayer class], @selector(isExternalPlaybackActive));
        method_setImplementation(method, (IMP)ret_NO);

        method = class_getInstanceMethod([AVPlayer class], @selector(isAirPlayVideoActive));
        method_setImplementation(method, (IMP)ret_NO);

        method = class_getInstanceMethod([AVPlayer class], @selector(allowsAirPlayVideo));
        //method_setImplementation(method, (IMP)ret_YES);
        method_setImplementation(method, (IMP)ret_NO);
    }
}