草庐IT

ios - skyway ios - 调整远程视频帧

coder 2024-01-22 原文

我在我的 iOS 应用程序中集成了 SkyWay SDK ( https://webrtc.ecl.ntt.com/en/ ) 以允许视频 session 。 我的问题是 - 我无法调整远程视频流帧以允许全屏流式传输?当我调整 rcRemote 的 CGRect 时,覆盖在该 View 上的视频不会调整大小,当我更改 maxWidth 和 maxHeight 约束时,框架不会改变。有没有根据您的要求自定义远程视频流帧?

[SKWNavigator initialize:_peer];

SKWMediaConstraints* constraints = [[SKWMediaConstraints alloc] init];
constraints.maxWidth = 960;
constraints.maxHeight = 540;
constraints.cameraPosition = SKW_CAMERA_POSITION_FRONT;

_msLocal = [SKWNavigator getUserMedia:constraints]; 
//////////////////// END: Get Local Stream   /////////////////////////

// Initialize views
if ((nil != self.navigationItem) && (nil == self.navigationItem.title))
{
    NSString* strTitle = @"Video Conference";
    [self.navigationItem setTitle:strTitle];
}

CGRect rcScreen = self.view.bounds;
if (NSFoundationVersionNumber_iOS_6_1 < NSFoundationVersionNumber)
{
    CGFloat fValue = [UIApplication sharedApplication].statusBarFrame.size.height;
    rcScreen.origin.y = fValue;
    if (nil != self.navigationController)
    {
        if (NO == self.navigationController.navigationBarHidden)
        {
            fValue = self.navigationController.navigationBar.frame.size.height;
            rcScreen.origin.y += fValue;
        }
    }
}

// Initialize Remote video view
CGRect rcRemote = CGRectZero;
if (UIUserInterfaceIdiomPad == [UIDevice currentDevice].userInterfaceIdiom)
{
    // iPad
    rcRemote.size.width = 480.0f;
    rcRemote.size.height = 480.0f;
}
else
{
    // iPhone / iPod touch
    rcRemote.size.width = rcScreen.size.width;
    rcRemote.size.height = rcRemote.size.width;
}
rcRemote.origin.x = (rcScreen.size.width - rcRemote.size.width) / 2.0f;
rcRemote.origin.y = (rcScreen.size.height - rcRemote.size.height) / 2.0f;
rcRemote.origin.y -= 8.0f;

// Initialize Local video view
CGRect rcLocal = CGRectZero;
if (UIUserInterfaceIdiomPad == [UIDevice currentDevice].userInterfaceIdiom)
{
    rcLocal.size.width = rcScreen.size.width / 5.0f;
    rcLocal.size.height = rcScreen.size.height / 5.0f;
}
else
{
    rcLocal.size.width = rcScreen.size.height / 5.0f;
    rcLocal.size.height = rcLocal.size.width;
}
rcLocal.origin.x = rcScreen.size.width - rcLocal.size.width - 8.0f;
rcLocal.origin.y = rcScreen.size.height - rcLocal.size.height - 8.0f;
rcLocal.origin.y -= self.navigationController.toolbar.frame.size.height;

// New frames for local and remote video views
CGRect rcRemoteNew;
rcRemoteNew.origin.x = 10.0;
rcRemoteNew.origin.y = 20.0;
rcRemoteNew.size.width = SCREEN_WIDTH - 10;
rcRemoteNew.size.height = SCREEN_HEIGHT/2 + 100;

CGRect rcLocalNew;
rcLocalNew.origin.x = SCREEN_WIDTH/2 - 50;
rcLocalNew.origin.y = SCREEN_HEIGHT/2;
rcLocalNew.size.width = 100;
rcLocalNew.size.height = 100;

////////////  START: Add Remote & Local SKWVideo to View   ///////////

SKWVideo* vwRemote = [[SKWVideo alloc] initWithFrame:rcRemote];
[vwRemote setTag:TAG_REMOTE_VIDEO];
[vwRemote setUserInteractionEnabled:NO];
[vwRemote setHidden:YES];
[self.view addSubview:vwRemote];

SKWVideo* vwLocal = [[SKWVideo alloc] initWithFrame:rcLocal];
[vwLocal setTag:TAG_LOCAL_VIDEO];
[self.view addSubview:vwLocal];

// Add local stream to local video view
[vwLocal addSrc:_msLocal track:0];

////////////  END: Add Remote & Local SKWVideo to View   /////////////

最佳答案

用这段代码替换你的代码

SKWMediaConstraints* constraints = [[SKWMediaConstraints alloc] init];
    constraints.maxWidth = 960;
    constraints.maxHeight = 540;

    //  constraints.cameraPosition = SKW_CAMERA_POSITION_BACK;
    constraints.cameraPosition = SKW_CAMERA_POSITION_FRONT;

    _msLocal = [SKWNavigator getUserMedia:constraints];

    //////////////////// END: Get Local Stream   /////////////////////////
    // Initialize views
    if ((nil != self.navigationItem) && (nil == self.navigationItem.title))
    {
        NSString* strTitle = @"Video Conference";
        [self.navigationItem setTitletrTitle];
    }

    CGRect rcScreen = self.view.bounds;
    if (NSFoundationVersionNumber_iOS_6_1 < NSFoundationVersionNumber)
    {
        CGFloat fValue = [UIApplication sharedApplication].statusBarFrame.size.height;
        rcScreen.origin.y = fValue;
        if (nil != self.navigationController)
        {
            if (NO == self.navigationController.navigationBarHidden)
            {
                fValue = self.navigationController.navigationBar.frame.size.height;
                rcScreen.origin.y += fValue;
            }
        }
    }

    // Initialize Local video view
    CGRect rcLocal = CGRectZero;
    if (UIUserInterfaceIdiomPad == [UIDevice currentDevice].userInterfaceIdiom)
    {
        rcLocal.size.width = rcScreen.size.width / 5.0f;
        rcLocal.size.height = rcScreen.size.height / 5.0f;
    }
    else
    {
        rcLocal.size.width = rcScreen.size.height / 5.0f;
        rcLocal.size.height = rcLocal.size.width;
    }
    rcLocal.origin.x = rcScreen.size.width - rcLocal.size.width - 8.0f;
    rcLocal.origin.y = rcScreen.size.height - rcLocal.size.height - 58.0f; // changed from 8 to 78 so to present this view above control views
    rcLocal.origin.y -= self.navigationController.toolbar.frame.size.height;

    // New frames for local and remote video views
    CGRect rcRemoteNew;
    rcRemoteNew.origin.x = 0.0;
    rcRemoteNew.origin.y = 0.0;
    rcRemoteNew.size.width = SCREEN_WIDTH;
    rcRemoteNew.size.height = SCREEN_HEIGHT;

    ////////////  START: Add Remote & Local SKWVideo to View   ///////////
    SKWVideo* vwRemote = [[SKWVideo alloc] initWithFrame:rcRemoteNew];
    [vwRemote setBackgroundColorUIColor blackColor]];
    [vwRemote setTag:TAG_REMOTE_VIDEO];
    [vwRemote setUserInteractionEnabled:NO];
    [vwRemote setHidden:YES];
    [baseView addSubview:vwRemote];

    SKWVideo* vwLocal = [[SKWVideo alloc] initWithFrame:rcLocal];
    [vwLocal setBackgroundColorUIColor clearColor]];
    [vwLocal setTag:TAG_LOCAL_VIDEO];
    [baseView addSubview:vwLocal];

    // Add local stream to local video view
    [vwLocal addSrc:_msLocal track:0];

    ////////////  END: Add Remote & Local SKWVideo to View   /////////////

关于ios - skyway ios - 调整远程视频帧,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46399936/

有关ios - skyway ios - 调整远程视频帧的更多相关文章

  1. ruby - 如何验证 IO.copy_stream 是否成功 - 2

    这里有一个很好的答案解释了如何在Ruby中下载文件而不将其加载到内存中:https://stackoverflow.com/a/29743394/4852737require'open-uri'download=open('http://example.com/image.png')IO.copy_stream(download,'~/image.png')我如何验证下载文件的IO.copy_stream调用是否真的成功——这意味着下载的文件与我打算下载的文件完全相同,而不是下载一半的损坏文件?documentation说IO.copy_stream返回它复制的字节数,但是当我还没有下

  2. Ruby 文件 IO 定界符? - 2

    我正在尝试解析一个文本文件,该文件每行包含可变数量的单词和数字,如下所示:foo4.500bar3.001.33foobar如何读取由空格而不是换行符分隔的文件?有什么方法可以设置File("file.txt").foreach方法以使用空格而不是换行符作为分隔符? 最佳答案 接受的答案将slurp文件,这可能是大文本文件的问题。更好的解决方案是IO.foreach.它是惯用的,将按字符流式传输文件:File.foreach(filename,""){|string|putsstring}包含“thisisanexample”结果的

  3. Get https://registry-1.docker.io/v2/: net/http: request canceled while waiting - 2

    1.错误信息:Errorresponsefromdaemon:Gethttps://registry-1.docker.io/v2/:net/http:requestcanceledwhilewaitingforconnection(Client.Timeoutexceededwhileawaitingheaders)或者:Errorresponsefromdaemon:Gethttps://registry-1.docker.io/v2/:net/http:TLShandshaketimeout2.报错原因:docker使用的镜像网址默认为国外,下载容易超时,需要修改成国内镜像地址(首先阿里

  4. 动漫制作技巧如何制作动漫视频 - 2

    动漫制作技巧是很多新人想了解的问题,今天小编就来解答与大家分享一下动漫制作流程,为了帮助有兴趣的同学理解,大多数人会选择动漫培训机构,那么今天小编就带大家来看看动漫制作要掌握哪些技巧?一、动漫作品首先完成草图设计和原型制作。设计草图要有目的、有对象、有步骤、要形象、要简单、符合实际。设计图要一致性,以保证制作的顺利进行。二、原型制作是根据设计图纸和制作材料,可以是手绘也可以是3d软件创建。在此步骤中,要注意的问题是色彩和平面布局。三、动漫制作制作完成后,加工成型。完成不同的表现形式后,就要对设计稿进行加工处理,使加工的难易度降低,并得到一些基本准确的概念,以便于后续的大样、准确的尺寸制定。四、

  5. python ffmpeg 使用 pyav 转换 一组图像 到 视频 - 2

    2022/8/4更新支持加入水印水印必须包含透明图像,并且水印图像大小要等于原图像的大小pythonconvert_image_to_video.py-f30-mwatermark.pngim_dirout.mkv2022/6/21更新让命令行参数更加易用新的命令行使用方法pythonconvert_image_to_video.py-f30im_dirout.mkvFFMPEG命令行转换一组JPG图像到视频时,是将这组图像视为MJPG流。我需要转换一组PNG图像到视频,FFMPEG就不认了。pyav内置了ffmpeg库,不需要系统带有ffmpeg工具因此我使用ffmpeg的python包装p

  6. TimeSformer:抛弃CNN的Transformer视频理解框架 - 2

    Transformers开始在视频识别领域的“猪突猛进”,各种改进和魔改层出不穷。由此作者将开启VideoTransformer系列的讲解,本篇主要介绍了FBAI团队的TimeSformer,这也是第一篇使用纯Transformer结构在视频识别上的文章。如果觉得有用,就请点赞、收藏、关注!paper:https://arxiv.org/abs/2102.05095code(offical):https://github.com/facebookresearch/TimeSformeraccept:ICML2021author:FacebookAI一、前言Transformers(VIT)在图

  7. ruby - 为什么不能使用类IO的实例方法noecho? - 2

    print"Enteryourpassword:"pass=STDIN.noecho(&:gets)puts"Yourpasswordis#{pass}!"输出:Enteryourpassword:input.rb:2:in`':undefinedmethod`noecho'for#>(NoMethodError) 最佳答案 一开始require'io/console'后来的Ruby1.9.3 关于ruby-为什么不能使用类IO的实例方法noecho?,我们在StackOverflow上

  8. ruby - 如何更改此正则表达式以从未指定 v 参数的 Youtube URL 获取 Youtube 视频 ID? - 2

    目前我正在使用这个正则表达式从YoutubeURL中提取视频ID:url.match(/v=([^&]*)/)[1]我怎样才能改变它,以便它也可以从这个没有v参数的YoutubeURL获取视频ID:http://www.youtube.com/user/SHAYTARDS#p/u/9/Xc81AajGUMU感谢阅读。编辑:我正在使用ruby​​1.8.7 最佳答案 对于Ruby1.8.7,这就可以了。url_1='http://www.youtube.com/watch?v=8WVTOUh53QY&feature=feedf'url

  9. 【Linux操作系统】——网络配置与SSH远程 - 2

    Linux操作系统——网络配置与SSH远程安装完VMware与系统后,需要进行网络配置。第一个目标为进行SSH连接,可以从本机到VMware进行文件传送,首先需要进行网络配置。1.下载远程软件首先需要先下载安装一款远程软件:FinalShell或者xhell7FinalShellxhell7FinalShell下载:Windows下载http://www.hostbuf.com/downloads/finalshell_install.exemacOS下载http://www.hostbuf.com/downloads/finalshell_install.pkg2.配置CentOS网络安装好

  10. ruby - 带有 grep 远程日志文件的 tail - 2

    我有这段代码来跟踪远程日志文件:defdo_tail(session,file)session.open_channeldo|channel|channel.on_datado|ch,data|puts"[#{file}]->#{data}"endchannel.exec"tail-f#{file}"endNet::SSH.start("host","user",:password=>"passwd")do|session|do_tailsession,"/path_to_log/file.log"session.loop我只想在file.log中检索带有ERROR字符串的行,我正在尝

随机推荐