语音和视频的捕获、编码解码以及渲染--开源技术大全


1. MediaStreamer2:   http://www.linphone.org/ 

http://hi.baidu.com/zui_chu_de_meng_xiang/blog/item/71d2d952ebaad6561038c286.html

Mediastreamer2 是一个支持多种平台的轻量级的流技术引擎,主要适合于开发语音和视频电话应用程序。该引擎主要为 linphone 的多媒体流的收发,包括语音和视频的捕获、编码解码以及渲染。

主要功能:

  • Read/Write from to an alsa device, an oss device, a windows waveapi device
  • Send and receive RTP/SRTP packets
  • DTMF (telephone tones) support using SIP INFO or RFC2833
  • Encode and decode the following formats: speex, G711, G772, GSM, H263, theora, iLBC, MPEG4, and H264, VP8 (WebM).
  • Read and write from/to a wav file
  • Read YUV pictures from a webcam (provided that it has video4linux v1 or v2 driver)
  • Display YUV pictures (using SDL library or native apis on windows)
  • Dual tones generation
  • Echo cancelation, using the extraordinary echo canceler algorithm from the speex library
  • Audio conferencing
  • Audio parametric equalizer using a FIR filter
  • Volume control, automatic gain control
  • Nat friendly: guesses NAT address for SIP messages, uses STUN for RTP streams
  • Sound backends: 
      • Linux: ALSA, OSS, PulseAudio
      • Windows: waveapi
      • MacOSX: HAL Audio Unit
      • iPhone: VoiceProcessing AudioUnit with built-in echo cancellation
      • Android sound system
      • JSR135 on BlackBerry
    • Efficient bandwidth management: the bandwidth limitations are signaled using SDP (b=AS...), resulting in audio and video session established with bitrates that fits the user's network capabilities.

Mediastreamer2  可通过插件进行扩展,当前提供了 H264 和 ILBC 编码器插件。

Some definitions.

Filter: A filter is a Mediastreamer2 component that process data. A filter has 0 or several INPUT pins and 0 or several OUTPUT pins. Here is a list of possible use of filters:

    capture audio or video data.

   play audio or display video data.

   send or receive RTP data.

   encode or decode audio or video data.

   mix audio/video data.

Graph: A graph is a manager of filters connected together. It will transfer data from OUTPUT pins to INPUT pins and will be responsible for running filters.

How do I use Mediastremer2?

Mediastreamer2 can be used for a lot of different purpose. The primary use is to manage RTP audio and video session. You will need to use the API to build filters, link them together in a graph. Then the ticker API will help you to start and stop the graph.

Basic graph sample:

AUDIO CAPTURE   -->   ENCODE -->     RTP

      FILTER      -->   FILTER -->    FILTER

The above graph is composed of three filters. The first one has no input: tt captures audio data directly from the drivers and provide it to the OUTPUT pin. This data is sent to the INPUT pin of the encoder which of course encode the data and send it to its OUTPUT pin. This pin is connected to the INPUT pin of a filter capable to build and send RTP packets.

The modular design helps you to encode in many different format just by replacing the "ENCODE FILTER" with another one. mediastreamer2 contains internal support for g711u, g711a, speex and gsm. You can add new encoding format by implementing new filters which can then be dynamically loaded.

List of existing filters.

Mediastreamer2 already provides a large set of filters. Here is a complete list of built-in filters.

All supported platforms:

   RTP receiver

RTP sender

Audio Filters:

   audio capture

   audio playback

   several audio encoder/decoder: PCMU, PCMA, speex, gsm

   wav file reader.

   wav file recorder.

   resampler.

   conference bridge.

   volume analyser.

   acoustic echo canceller.

   dtmf generation filter.

Video Filters:

   video capture

   video display

   several audio encoder/decoder: H263-1998, MP4V-ES, theora

   image resizer.

   format converter. (RBG24, I420...)

Plugin Filters:

iLBC decoder/encoder.

Refer to : http://download.savannah.gnu.org/releases-noredirect/linphone/mediastreamer/doc/group__mediastreamer2.html

Mediastreamer2 - the multimedia streaming engine

Mediastreamer2 is a powerful and light weighted streaming engine specialized for voice/video telephony applications.

It is the library that is responsible for all the receiving and sending of multimedia streams in linphone, including voice/video capture, encoding and decoding, and rendering.

Features

★   Read/Write from to an alsa device, an oss device, a windows waveapi device

★   Send and receive RTP packets

★   Encode and decode the following formats: speex, G711, GSM, H263, theora, iLBC, MPEG4, and H264.

★   Read and write from/to a wav file

★   Dual tones generation

★   Echo cancelation, using the extraordinary echo canceller algorithm from the speex library

★   Audio conferencing

★   Audio parametric equalizer using a FIR filter

★   Volume control, automatic gain control

★   Works on linux, windows XP

Mediastreamer2 can be extended with dynamic plugins, currently a H264 and an ILBC codec plugins are available.

Design and principles

Each processing entity is contained within a MSFilter object. MSFilter(s) have inputs and/or outputs that can be used to connect from and to other MSFilters.

A trivial example to understand:

☆   MSRtpRecv is a MSFilter that receives RTP packets from the network, unpacketize them and post them on its only output.

☆   MSSpeexDec is a MSFilter that takes everything on its input assuming these are speex encoded packets, and decodes them and put the result on its output.

☆   MSFileRec is a MSFilter that takes everything on its input and write it to wav file (assuming the input is 16bit linear pcm).

MSFilters can be connected together to become filter chain. If we assemble the three above examples, we obtain a processing chain that receives RTP packet, decode them and write the uncompressed result into a wav file.

The execution of the media processing work is scheduled by a MSTicker object, a thread that wakes up every 10 ms to process data in all the MSFilter chains it manages. Several MSTicker can be used simultaneously, for example one for audio filters, one for video filters, or one on each processor of the machine where it runs.

Mediastreamer2 is easy to use

If your intent is simply to create audio and video streams, a simple API is defined in audiostream.h and videostream.h to create audio and video stream.

It can be as simple as:

AudioStream *as=audio_stream_start(.../*list of parameters*/);sleep(10);
audio_stream_stop(as);

If your intent is to add new functionalities to mediastreamer2, you'll be glad to know that implementing a mediastreamer2 filter is very straightforward: no complex declarations, inheritance or such like this.

As an example, have a look at this: it is the 'MSVolume' MSFilter, whose goal is to measure and control loudness of an audio stream.

Thanks to this lightweighted framework, developers can concentrate on what matters: the implementation of the algorithm !

Mediastreamer2 is also suitable for embedded systems

★   Mediastreamer2 is light. For example on linux/x86 the full-featured shared library takes around 800ko unstripped and compiled with -g (debug). Data messages that carries the media data within mediastreamer2 chains are optimized using the famous sys-V mblk_t structure. This is to avoid copies as long it is possible and allow low cost fragmentation/re-assemble operations that are very common especially when processing video streams.

★   Mediastreamer2 is written in C.

★   Mediastreamer2 compiles on arm with gcc.

★   Mediastreamer2 has only oRTP and libc as minimal dependencies. Others (ffmpeg, speex, alsa...) can be added optionnaly if you need all features.

Thanks to its plugin architecture, mediastreamer2 can be extended to interface with hardware codecs, for example video codecs dsp.




2.  

  • 1
    点赞
  • 9
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值