找回密码
 立即注册
搜索
查看: 99|回复: 0

腾讯视频云 RTMP SDK:功能强大,使用简单,助您轻松实现视频直播

[复制链接]

2万

主题

0

回帖

6万

积分

管理员

积分
63566
发表于 2024-10-22 02:34:31 | 显示全部楼层 |阅读模式
功能

腾讯视频云RTMP SDK由推流器+播放器两部分组成。本文将主要介绍推流器的相关信息。

SDK遵循标准RTMP视频推送协议,可连接腾讯云等标准视频直播服务器。同时,该SDK包含了腾讯音视频团队多年的技术积累,在视频压缩、硬件加速、美颜滤镜、音频降噪、码率控制等方面做了诸多优化。

如果您是刚接触视频直播的伙伴,只需要几行代码即可完成对接过程。如果您是资深的移动软件开发工程师,也可以使用SDK提供的丰富的设置接口。允许您定制最适合您需求的性能。

SDK开发包附带的推送器DEMO界面如下:

基础知识

腾讯视频云RTMP SDK的使用非常简单。您只需要在您的App中添加以下几行代码即可完成对接工作。目前SDK内的默认参数设置已经参考直播场景进行了精心校准。

步骤一:添加界面元素

为了显示推送预览界面,您需要将以下代码添加到您的布局xml文件中:

<p><pre style="list-style:inherit; margin-top:0px; margin-bottom:0px; font-family:Consolas,"Liberation Mono",Menlo,Courier,monospace; padding:16px; overflow:auto; line-height:1.45; background-color:rgb(247,247,247); word-wrap:normal">    <code class="lang-xml" style="list-style:inherit; padding:0px; margin:0px; background-color:transparent; font-family:Consolas,"Liberation Mono",Menlo,Courier,"Microsoft Yahei",monospace; display:inline; max-width:initial; overflow:initial; line-height:inherit; word-wrap:normal; border:0px; word-break:normal"><span class="hljs-tag" style="list-style:inherit; color:navy"><<span class="hljs-name" style="list-style:inherit">com.tencent.rtmp.ui.TXCloudVideoView</span>
            <span class="hljs-attr" style="list-style:inherit; color:teal">android:id</span>=<span class="hljs-string" style="list-style:inherit; color:rgb(221,17,68)">"@+id/video_view"</span>
            <span class="hljs-attr" style="list-style:inherit; color:teal">android:layout_width</span>=<span class="hljs-string" style="list-style:inherit; color:rgb(221,17,68)">"match_parent"</span>
            <span class="hljs-attr" style="list-style:inherit; color:teal">android:layout_height</span>=<span class="hljs-string" style="list-style:inherit; color:rgb(221,17,68)">"match_parent"</span>
            <span class="hljs-attr" style="list-style:inherit; color:teal">android:layout_centerInParent</span>=<span class="hljs-string" style="list-style:inherit; color:rgb(221,17,68)">"true"</span>
            <span class="hljs-attr" style="list-style:inherit; color:teal">android:visibility</span>=<span class="hljs-string" style="list-style:inherit; color:rgb(221,17,68)">"gone"</span>/></span>
</code></pre></p>
第2步:创建对象

首先创建一个对象,它是所有SDK调用接口的承载。

<p><pre style="list-style:inherit; margin-top:0px; margin-bottom:0px; font-family:Consolas,"Liberation Mono",Menlo,Courier,monospace; padding:16px; overflow:auto; line-height:1.45; background-color:rgb(247,247,247); word-wrap:normal">    <code class="lang-java" style="list-style:inherit; padding:0px; margin:0px; background-color:transparent; font-family:Consolas,"Liberation Mono",Menlo,Courier,"Microsoft Yahei",monospace; display:inline; max-width:initial; overflow:initial; line-height:inherit; word-wrap:normal; border:0px; word-break:normal">TXLivePusher mLivePusher = <span class="hljs-keyword" style="list-style:inherit; color:rgb(51,51,51); font-weight:700">new</span> TXLivePusher(getActivity());
</code></pre></p>
第3步:开始推流

使用如下代码完成推送:

<p><pre style="list-style:inherit; margin-top:0px; margin-bottom:0px; font-family:Consolas,"Liberation Mono",Menlo,Courier,monospace; padding:16px; overflow:auto; line-height:1.45; background-color:rgb(247,247,247); word-wrap:normal">    <code class="lang-java" style="list-style:inherit; padding:0px; margin:0px; background-color:transparent; font-family:Consolas,"Liberation Mono",Menlo,Courier,"Microsoft Yahei",monospace; display:inline; max-width:initial; overflow:initial; line-height:inherit; word-wrap:normal; border:0px; word-break:normal">String rtmpUrl = <span class="hljs-string" style="list-style:inherit; color:rgb(221,17,68)">"rtmp://2157.livepush.myqcloud.com/live/xxxxxx"</span>;
mLivePusher.startPusher(rtmpUrl);
TXCloudVideoView mCaptureView = (TXCloudVideoView) <span class="hljs-keyword" style="list-style:inherit; color:rgb(51,51,51); font-weight:700">view</span>.findViewById(<span class="hljs-keyword" style="list-style:inherit; color:rgb(51,51,51); font-weight:700">R</span>.id.video_view);
mLivePusher.startCameraPreview(mCaptureView);
</code></pre></p>
用于告诉SDK应该将视频流推送到哪个服务器地址,并关联界面元素和对象,以便将手机摄像头拍摄的图像渲染到屏幕上。

【小细节】

传入的self.view将作为屏幕渲染视图的父视图。建议将此父视图专门用于渲染。如果你想在相机屏幕上添加弹幕、鲜花等UI控件,请创建一个单独的视图,A视图与self.view平齐,并将该视图叠加在self.view之上。

第四步:美颜滤镜

如果你的目标是美容秀,美容是必不可少的功能。该SDK提供了简单版本的实现,包括换肤(1级-&gt;10级)和美白(1级-&gt;3级)两个功能。您可以在APP的用户界面上使用滑块等控件来让用户选择美化效果,或者建议您先使用Demo中的滑块。达到您满意的效果后,将此时的值固定在程序的设置参数中。

界面函数可以动态调整美化和美白级别(极少数不支持Neon命令优化的手机无法开启):

<p><pre style="list-style:inherit; margin-top:0px; margin-bottom:0px; font-family:Consolas,"Liberation Mono",Menlo,Courier,monospace; padding:16px; overflow:auto; line-height:1.45; background-color:rgb(247,247,247); word-wrap:normal">    <code class="lang-java" style="list-style:inherit; padding:0px; margin:0px; background-color:transparent; font-family:Consolas,"Liberation Mono",Menlo,Courier,"Microsoft Yahei",monospace; display:inline; max-width:initial; overflow:initial; line-height:inherit; word-wrap:normal; border:0px; word-break:normal"><span class="hljs-keyword" style="list-style:inherit; color:rgb(51,51,51); font-weight:700">if</span> (!mLivePusher.setBeautyFilter(mBeautyLevel, mWhiteningLevel)) {
    Toast.makeText(getActivity().getApplicationContext(), <span class="hljs-string" style="list-style:inherit; color:rgb(221,17,68)">"当前机型的性能无法支持美颜功能"</span>,
            Toast.LENGTH_SHORT).show();
}
</code></pre></p>
第5步:控制相机

<p><pre style="list-style:inherit; margin-top:0px; margin-bottom:0px; font-family:Consolas,"Liberation Mono",Menlo,Courier,monospace; padding:16px; overflow:auto; line-height:1.45; background-color:rgb(247,247,247); word-wrap:normal">    <code class="lang-java" style="list-style:inherit; padding:0px; margin:0px; background-color:transparent; font-family:Consolas,"Liberation Mono",Menlo,Courier,"Microsoft Yahei",monospace; display:inline; max-width:initial; overflow:initial; line-height:inherit; word-wrap:normal; border:0px; word-break:normal">    <span class="hljs-comment" style="list-style:inherit; color:rgb(153,153,136); font-style:italic">// 默认是前置摄像头</span>
    mLivePusher.switchCamera();
</code></pre></p>
<p><pre style="list-style:inherit; margin-top:0px; margin-bottom:0px; font-family:Consolas,"Liberation Mono",Menlo,Courier,monospace; padding:16px; overflow:auto; line-height:1.45; background-color:rgb(247,247,247); word-wrap:normal">    <code class="lang-java" style="list-style:inherit; padding:0px; margin:0px; background-color:transparent; font-family:Consolas,"Liberation Mono",Menlo,Courier,"Microsoft Yahei",monospace; display:inline; max-width:initial; overflow:initial; line-height:inherit; word-wrap:normal; border:0px; word-break:normal">    //mFlashTurnOn为<span class="hljs-literal" style="list-style:inherit; color:teal">true</span>表示打开,否则表示关闭
    <span class="hljs-keyword" style="list-style:inherit; color:rgb(51,51,51); font-weight:700">if</span> (!mLivePusher.turnOnFlashLight(mFlashTurnOn)) {
        Toast.makeText(getActivity().getApplicationContext(),
            <span class="hljs-string" style="list-style:inherit; color:rgb(221,17,68)">"打开闪光灯失败:绝大部分手机不支持前置闪光灯!"</span>, Toast.LENGTH_SHORT).show();
    }
</code></pre></p>
第6步:设置Logo水印

这里需要特别说明的是,腾讯云支持两种设置水印的方式:一种是在流媒体SDK中设置。原理是在SDK内部进行视频编码之前对图片进行水印。另一种方式是云端水印,即云端解析视频并添加水印标识。

这里特别推荐大家使用SD​​K添加水印,因为云端水印存在三个明显的问题:

(1) 这是一项机器密集型服务,会增加您的成本;

(2) 云端水印在直播过程中切换分辨率并不理想,会出现很多画面模糊的问题。

(3)云中的水印会引入超过3秒的额外视频延迟,这是由转码服务引入的。

SDK要求的水印图片格式为png,因为png图片格式具有透明度信息,可以更好的处理锯齿等问题。 (千万不能只是改变jpg图片的后缀名就插入进去,专业的png图标需要经过专业的美术设计师处理)

<p><pre style="list-style:inherit; margin-top:0px; margin-bottom:0px; font-family:Consolas,"Liberation Mono",Menlo,Courier,monospace; padding:16px; overflow:auto; line-height:1.45; background-color:rgb(247,247,247); word-wrap:normal">    <code class="lang-java" style="list-style:inherit; padding:0px; margin:0px; background-color:transparent; font-family:Consolas,"Liberation Mono",Menlo,Courier,"Microsoft Yahei",monospace; display:inline; max-width:initial; overflow:initial; line-height:inherit; word-wrap:normal; border:0px; word-break:normal">    <span class="hljs-comment" style="list-style:inherit; color:rgb(153,153,136); font-style:italic">//设置视频水印</span>
    mLivePushConfig.setWatermark(BitmapFactory.decodeResource(getResources(),<span class="hljs-keyword" style="list-style:inherit; color:rgb(51,51,51); font-weight:700">R</span>.drawable.watermark), <span class="hljs-number" style="list-style:inherit; color:teal">10</span>, <span class="hljs-number" style="list-style:inherit; color:teal">10</span>);
    mLivePusher.setConfig(mLivePushConfig);
</code></pre></p>
第7步:硬件编码

可以通过 ion 接口启用硬件编码。

<p><pre style="list-style:inherit; margin-top:0px; margin-bottom:0px; font-family:Consolas,"Liberation Mono",Menlo,Courier,monospace; padding:16px; overflow:auto; line-height:1.45; background-color:rgb(247,247,247); word-wrap:normal">    <code class="lang-java" style="list-style:inherit; padding:0px; margin:0px; background-color:transparent; font-family:Consolas,"Liberation Mono",Menlo,Courier,"Microsoft Yahei",monospace; display:inline; max-width:initial; overflow:initial; line-height:inherit; word-wrap:normal; border:0px; word-break:normal"><span class="hljs-keyword" style="list-style:inherit; color:rgb(51,51,51); font-weight:700">if</span> (!HWSupportList.isHWVideoEncodeSupport()){
    Toast.makeText(getActivity().getApplicationContext(),
                   <span class="hljs-string" style="list-style:inherit; color:rgb(221,17,68)">"当前手机型号未加入白名单或API级别过低(最低16),请慎重开启硬件编码!"</span>,
                   Toast.LENGTH_SHORT).show();
}
mLivePushConfig.setHardwareAcceleration(mHWVideoEncode);
mLivePusher.setConfig(mLivePushConfig);
</code></pre></p>
它是硬件编码的吗?

如果你的产品定位于美容秀,主要使用360*640的分辨率,硬件编码并不比软编码好。由于硬编码的不确定性比IOS高很多,所以建议您不要启用。

如果你的产品定位于高清场景,540p或者720p高清推流,建议尽量开启,因为手机的CPU降频策略,以及目前多核的情况但每个核心的晶体管很少,注定要使用软编码来处理 540p。这是非常困难的,所以硬件编码可以支持帧率到20帧以上。

白名单策略

目前我们在Demo的.java文件中有一个白名单列表。以下是我们自己的团队已经测试过并且可以安全启用硬件加速的模型。未来我们将继续增加此列表中的型号数量。

目前RTMP SDK测试团队已测试的模型及通过情况显示在模型列表中,供大家参考。

定制化

刚才讲的是最基本的使用方法,可以满足大部分需求。

如果您是高级软件开发工程师,可能会有更专业的要求。比如你可能会关心SDK的运行状态,或者你可能会尝试自定义一些视频参数等。接下来我们来看看高级用途:

1.如果你关心内部原则

首先,您需要了解视频云RTMP SDK的内部原理。推流模式下,SDK内部状态机制如下:



简单的描述就是,你调用后,RTMP SDK会尝试连接网络,启动摄像头和麦克风的音视频采集。如果一切顺利,它将进入主流循环。之后,如果一切顺利,SDK将在内部每秒处理一次。通知频率的当前内部状态(网络)。如果过程中出现任何问题,都会以事件或者错误的形式进行通知。

2.如果你关心地位

要获取RTMP SDK的状态通知,你可以向刚才提到的对象提供一个,然后所有关于SDK的信息都会通过这个反馈给你的App。

<p><pre style="list-style:inherit; margin-top:0px; margin-bottom:0px; font-family:Consolas,"Liberation Mono",Menlo,Courier,monospace; padding:16px; overflow:auto; line-height:1.45; background-color:rgb(247,247,247); word-wrap:normal">    <code class="lang-java" style="list-style:inherit; padding:0px; margin:0px; background-color:transparent; font-family:Consolas,"Liberation Mono",Menlo,Courier,"Microsoft Yahei",monospace; display:inline; max-width:initial; overflow:initial; line-height:inherit; word-wrap:normal; border:0px; word-break:normal"><span class="hljs-keyword" style="list-style:inherit; color:rgb(51,51,51); font-weight:700">public</span> <span class="hljs-class" style="list-style:inherit"><span class="hljs-keyword" style="list-style:inherit; color:rgb(51,51,51); font-weight:700">class</span> <span class="hljs-title" style="list-style:inherit; color:rgb(68,85,136); font-weight:700">MyTestActivity</span> <span class="hljs-keyword" style="list-style:inherit; color:rgb(51,51,51); font-weight:700">implements</span> <span class="hljs-title" style="list-style:inherit; color:rgb(68,85,136); font-weight:700">ITXLivePushListener</span></span>{
    <span class="hljs-meta" style="list-style:inherit; color:rgb(153,153,153); font-weight:700">@Override</span>
    <span class="hljs-function" style="list-style:inherit"><span class="hljs-keyword" style="list-style:inherit; color:rgb(51,51,51); font-weight:700">public</span> <span class="hljs-keyword" style="list-style:inherit; color:rgb(51,51,51); font-weight:700">void</span> <span class="hljs-title" style="list-style:inherit; color:rgb(153,0,0); font-weight:700">onPushEvent</span><span class="hljs-params" style="list-style:inherit">(<span class="hljs-keyword" style="list-style:inherit; color:rgb(51,51,51); font-weight:700">int</span> event, Bundle param)</span> </span>{
        <span class="hljs-comment" style="list-style:inherit; color:rgb(153,153,136); font-style:italic">// your code</span>
    }
     <span class="hljs-function" style="list-style:inherit"><span class="hljs-keyword" style="list-style:inherit; color:rgb(51,51,51); font-weight:700">public</span> <span class="hljs-keyword" style="list-style:inherit; color:rgb(51,51,51); font-weight:700">void</span> <span class="hljs-title" style="list-style:inherit; color:rgb(153,0,0); font-weight:700">onNetStatus</span><span class="hljs-params" style="list-style:inherit">(Bundle status)</span> </span>{
        <span class="hljs-comment" style="list-style:inherit; color:rgb(153,153,136); font-style:italic">// your code</span>
    }
}
mLivePusher.setPushListener(<span class="hljs-keyword" style="list-style:inherit; color:rgb(51,51,51); font-weight:700">this</span>);
</code></pre></p>
事件通知 事件ID 数值含义 解释

C

1001

成功连接腾讯云直播服务器

1002

与服务器握手完成,一切正常,准备开始直播。

_上海交通大学

1003

主播已成功打开相机(部分手机此过程需要1-2秒)

事件ID数值含义解释



1101

网络状况差:上行带宽过小,数据上传受阻。

CT

1102

网络断开,已启动自动重连(连续失败3次以上自动重连放弃)

1103

硬编码启动失败,使用软编码

L

3001

RTMP -DNS解析失败(将触发重试过程)

3002

RTMP服务器连接失败(会触发重试流程)

铝型材

3003

RTMP服务器握手失败(会触发重试流程)

事件ID数值含义解释

_失败

-1301

无法打开相机

伊尔

-1302

无法打开麦克风

-1303

视频编码失败

-1304

音频编码失败

-1305

不支持的视频分辨率

-1306

不支持的音频采样率

ECT

-1307

网络断线,三次救援均无效。您可以放弃治疗。请自行重启直播以进行更多重试。

事件定义请参考头文件“.java”



网络状态回调

该通知将每秒触发一次,以提供当前推送器状态的实时反馈:

评价参数含义说明

速度

当前视频编码器输出的码率,即编码器每秒产生多少视频数据,单位为kbps

速度

当前音频编码器输出的比特率,即编码器每秒产生多少音频数据,单位为kbps

当前视频帧率,即视频编码器每个视频产生多少帧

当前发送速度



网络抖动。抖动越大,网络越不稳定。



缓冲区大小。缓冲区越大,当前上行带宽越大。说明当前上行带宽不足以消耗已经产生的视频数据。

3.如果你关心参数

如果您想自定义视频编码参数、音频编码参数等,可以通过设置对象来实现您的自定义需求。目前我们支持的接口如下:

参数名称含义默认值

音频采样率:录音设备在一秒钟内采集声音信号的次数

44100

噪声抑制:开启时可以滤除背景噪声(采样率低于32000有效)

关闭

视频帧率:即视频编码器每秒产生多少帧。请注意,由于大多数机器相机不支持30FPS以上的拍摄,因此建议您将FPS设置为20

20

视频分辨率:目前有三种16:9分辨率可供选择

640*360

视频比特率:视频编码器每秒产生多少数据,单位kbps

800

关键帧间隔(单位:秒)是多少秒生成一个I帧。

5秒

带宽适配:该功能会根据当前网络情况自动调整视频码率,避免视频数据超出发送能力而造成卡顿。

打开

最大输出码率:此设置仅在自适应码率开启时才生效

1200

最小输出码率:此设置仅在自适应码率开启时才生效

800

设置水印图像及其相对于屏幕左上角的位置

腾讯云Logo(演示)

设置视频图像的旋转角度,比如是否水平推流

家在右边 (0) 家在下面 (1) 家在左边 (2) 家在上面 (3)

建议您在开始推送之前指定这些参数的设置,因为大部分设置要等到再次推送流后才会生效。参考代码如下:

<p><pre style="list-style:inherit; margin-top:0px; margin-bottom:0px; font-family:Consolas,"Liberation Mono",Menlo,Courier,monospace; padding:16px; overflow:auto; line-height:1.45; background-color:rgb(247,247,247); word-wrap:normal">    <code class="lang-java" style="list-style:inherit; padding:0px; margin:0px; background-color:transparent; font-family:Consolas,"Liberation Mono",Menlo,Courier,"Microsoft Yahei",monospace; display:inline; max-width:initial; overflow:initial; line-height:inherit; word-wrap:normal; border:0px; word-break:normal"><span class="hljs-comment" style="list-style:inherit; color:rgb(153,153,136); font-style:italic">// 成员变量中声明 config 和 pusher</span>
<span class="hljs-keyword" style="list-style:inherit; color:rgb(51,51,51); font-weight:700">private</span> TXLivePushConfig mLivePushConfig = <span class="hljs-keyword" style="list-style:inherit; color:rgb(51,51,51); font-weight:700">new</span> TXLivePushConfig();
<span class="hljs-keyword" style="list-style:inherit; color:rgb(51,51,51); font-weight:700">private</span> TXLivePusher     mLivePusher = <span class="hljs-keyword" style="list-style:inherit; color:rgb(51,51,51); font-weight:700">new</span> TXLivePusher(getActivity());
<span class="hljs-comment" style="list-style:inherit; color:rgb(153,153,136); font-style:italic">// 修改参数设置</span>
mLivePushConfig.setVideoResolution(TXLiveConstants.VIDEO_RESOLUTION_640_360);
mLivePushConfig.setAutoAdjustBitrate(<span class="hljs-literal" style="list-style:inherit; color:teal">false</span>);
mLivePushConfig.setVideoBitrate(<span class="hljs-number" style="list-style:inherit; color:teal">800</span>);
<span class="hljs-comment" style="list-style:inherit; color:rgb(153,153,136); font-style:italic">//设置视频水印</span>
mLivePushConfig.setWatermark(BitmapFactory.decodeResource(
    getResources(),R.drawable.watermark), <span class="hljs-number" style="list-style:inherit; color:teal">10</span>, <span class="hljs-number" style="list-style:inherit; color:teal">10</span>);
mLivePusher.setConfig(mLivePushConfig);
</code></pre></p>
4.如果你想自己处理视频数据

一些研发能力较强的客户会有定制图像处理需求(如定制图像滤镜),同时希望复用RTMP SDK的整体流程。如果是这样,您可以根据以下指南进行自定义。

5.如果你想自己处理音频数据

与视频数据处理思路类似,但具体函数和参数名称要替换为音频相关的。 java层的示例代码如下:

<p><pre style="list-style:inherit; margin-top:0px; margin-bottom:0px; font-family:Consolas,"Liberation Mono",Menlo,Courier,monospace; padding:16px; overflow:auto; line-height:1.45; background-color:rgb(247,247,247); word-wrap:normal">    <code class="lang-java" style="list-style:inherit; padding:0px; margin:0px; background-color:transparent; font-family:Consolas,"Liberation Mono",Menlo,Courier,"Microsoft Yahei",monospace; display:inline; max-width:initial; overflow:initial; line-height:inherit; word-wrap:normal; border:0px; word-break:normal">customMode |= TXLiveConstants.CUSTOM_MODE_AUDIO_PREPROCESS; <span class="hljs-comment" style="list-style:inherit; color:rgb(153,153,136); font-style:italic">//可以和VIDEO_PREPROCESS一起设置</span>
<span class="hljs-built_in" style="list-style:inherit; color:rgb(0,134,179)">String</span> path = <span class="hljs-keyword" style="list-style:inherit; color:rgb(51,51,51); font-weight:700">this</span>.getActivity().getApplicationInfo().dataDir + <span class="hljs-string" style="list-style:inherit; color:rgb(221,17,68)">"/lib"</span>;
mLivePushConfig.setCustomModeType(customMode);
mLivePushConfig.setCustomAudioPreProcessLibrary(path +<span class="hljs-string" style="list-style:inherit; color:rgb(221,17,68)">"/libtest.so"</span>, <span class="hljs-string" style="list-style:inherit; color:rgb(221,17,68)">"MyAudioProcessFunc"</span>);
</code></pre></p>
应遵循以下函数声明:

<p><pre style="list-style:inherit; margin-top:0px; margin-bottom:0px; font-family:Consolas,"Liberation Mono",Menlo,Courier,monospace; padding:16px; overflow:auto; line-height:1.45; background-color:rgb(247,247,247); word-wrap:normal">    <code class="lang-C" style="list-style:inherit; padding:0px; margin:0px; background-color:transparent; font-family:Consolas,"Liberation Mono",Menlo,Courier,"Microsoft Yahei",monospace; display:inline; max-width:initial; overflow:initial; line-height:inherit; word-wrap:normal; border:0px; word-break:normal"><span class="hljs-comment" style="list-style:inherit; color:rgb(153,153,136); font-style:italic">/* @brief 客户自定义的音频预处理函数原型
* @param pcm_buffer:   音频PCM数据
* @param len_buffer:   数据长度
* @param sample_rate:  采样频率
* @param channels:     声道数
* @param bit_size:     采样位宽
* @return
* @remark (1)该函数会被SDK同步调用,故您需要同步返回预处理后的数据
*         (2)处理后的数据长度必须和处理前保持一致
*         (3)您或者直接处理pcm_buffer,或者将处理后的数据memcpy到pcm_buffer所指的内存区域,
*             这块内存的生命期由SDK负责管理(也就是释放)
*/</span>
<span class="hljs-function" style="list-style:inherit"><span class="hljs-keyword" style="list-style:inherit; color:rgb(51,51,51); font-weight:700">typedef</span> <span class="hljs-title" style="list-style:inherit; color:rgb(153,0,0); font-weight:700">void</span> <span class="hljs-params" style="list-style:inherit">(*PAudioProcessHookFunc)</span><span class="hljs-params" style="list-style:inherit">(<span class="hljs-keyword" style="list-style:inherit; color:rgb(51,51,51); font-weight:700">unsigned</span> <span class="hljs-keyword" style="list-style:inherit; color:rgb(51,51,51); font-weight:700">char</span> * pcm_buffer, <span class="hljs-keyword" style="list-style:inherit; color:rgb(51,51,51); font-weight:700">int</span> len_buffer,
                                          <span class="hljs-keyword" style="list-style:inherit; color:rgb(51,51,51); font-weight:700">int</span> sample_rate, <span class="hljs-keyword" style="list-style:inherit; color:rgb(51,51,51); font-weight:700">int</span> channels, <span class="hljs-keyword" style="list-style:inherit; color:rgb(51,51,51); font-weight:700">int</span> bit_size)</span></span>;
</code></pre></p>
6. 如果您只使用SDK推流

也有客户只是想使用SDK进行流媒体播放。音视频采集部分由自己的代码控制,可以使用SDK进行音视频编码和推流。

如果是这样,您可以执行以下操作:
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

Archiver|手机版|小黑屋|【智道时空】 ( 京ICP备20013102号-16 )

GMT+8, 2025-5-11 16:30 , Processed in 0.072521 second(s), 20 queries .

Powered by Discuz! X3.5

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表