全网首发:FreeSwitch硬解失败后切换到软解

简介: 全网首发:FreeSwitch硬解失败后切换到软解

 给FreeSwitch集成了NV硬解。前几天突然报告说,登录A服务器,转发会议命令到B服务器后,一直没画面。跟踪了一下,是硬解一直失败。怎么办?先切换到软解,有时间再研究怎么回事。


  • 正常来说,开始的时候,硬解返回数据都是空(因为是异步的)。所以,吾设定失败16次后切换。
  • 切换代码如下:


/

static int init_decoder(h264_codec_context_t *context, final int hw, final int release)
{
    avcodec_profile_t *profile = NULL;
  profile = find_profile(get_profile_name(context->av_codec_id), SWITCH_FALSE);
  if (!profile) {
    return -1;
  }
    if (context->decoder_ctx && release)
  {
    if (context->decoder_ctx) {
      LOG_TEXT("avcodec_close()");
      if (avcodec_is_open(context->decoder_ctx)) avcodec_close(context->decoder_ctx);
      av_free(context->decoder_ctx);
      context->decoder_ctx = NULL;
    }
    context->decoder = NULL;
#ifdef NVIDIA_H264_DECODER
    if (context->hw_decoder)
    {
      LOG_TEXT("nv_decoder_release()");
      nv_decoder_release(&(context->nv_context));
      memset(&(context->nv_context), 0, sizeof(h264_nv_decode_context_t));
      context->hw_decoder = 0;
      context->nv_error_count = 0;
    }
#endif
  }
#ifdef NVIDIA_H264_DECODER
  if (hw && !context->decoder)
  {
      LOG_TEXT("get_nv_decoder()");
    get_nv_decoder(context->av_codec_id, &(context->decoder), &(context->hw_decoder));
  }
#endif
  if (!context->decoder)
  {
    LOG_TEXT("avcodec_find_decoder()");
    context->decoder = avcodec_find_decoder(context->av_codec_id);
    if (!context->decoder && context->av_codec_id == AV_CODEC_ID_H263P) {
      switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Cannot find AV_CODEC_ID_H263P decoder, trying AV_CODEC_ID_H263 instead\n");
      context->decoder = avcodec_find_decoder(AV_CODEC_ID_H263);
    }
    if (!context->decoder) {
      return -1;
    }
  }
  switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "DECODER: id=%d %s\n", context->decoder->id, context->decoder->long_name);
  context->decoder_ctx = avcodec_alloc_context3(context->decoder);
  context->decoder_ctx->thread_count = profile->decoder_thread_count;
  if (avcodec_open2(context->decoder_ctx, context->decoder, NULL) < 0) {
    return -1;
  }
  return 0;
}
目录
相关文章
|
安全 网络安全
QQ上不了,下载慢,先不要慌,先看看是不是华为防火墙上做了手脚
QQ上不了,下载慢,先不要慌,先看看是不是华为防火墙上做了手脚
145 0
|
存储 关系型数据库 MySQL
终端连接MySQL进行操作(全网超详细的教程,手把手教你)
终端连接MySQL进行操作(全网超详细的教程,手把手教你)
576 0
全网首发:麒麟平台更新时提示错误:无法解析域名“archive.kylinos.cn”
全网首发:麒麟平台更新时提示错误:无法解析域名“archive.kylinos.cn”
1986 1
|
4月前
|
前端开发 JavaScript CDN
一文搞懂:免费观看全网VIP视频资源
一文搞懂:免费观看全网VIP视频资源
184 0
|
Linux
全网首发:LINUX给进程内容窗口改名的第二种方法
全网首发:LINUX给进程内容窗口改名的第二种方法
106 0
|
并行计算 程序员 块存储
全网首发:DeepStream中,获得视频帧数据的代码
全网首发:DeepStream中,获得视频帧数据的代码
275 0
|
Linux 测试技术
全网首发:j3d/jogl多个崩溃分析总结
全网首发:j3d/jogl多个崩溃分析总结
117 0
|
Kubernetes 网络协议 Linux
五分钟带你玩转k8s(三)全网最新最全搭建master方式,楼主亲测可用
五分钟带你玩转k8s(三)全网最新最全搭建master方式,楼主亲测可用
321 0
五分钟带你玩转k8s(三)全网最新最全搭建master方式,楼主亲测可用
|
Kubernetes 网络协议 API
全网最全最新安装nodes方式,楼主亲测好用
全网最全最新安装nodes方式,楼主亲测好用
140 0
全网最全最新安装nodes方式,楼主亲测好用