Mediastream. C with video and audio

Source: Internet
Author: User

Before Running mediastream. C, make sure that you have compiled ortp, FFMPEG, x264, speex, msx264, and mediastream2. For details about the compilation, see my previous two articles compiling mediastreamer2 and FFMPEG.

------------------------------------------------------------------------

First, let's take a look at mediastreamer2.

This program is not implemented: Two sessions are used to simultaneously transmit video and audio.

It uses a full-duplex session to transmit video or audio. The same program runs on both the local host and remote host, and only one payload can be selected at a time.

1. Use the filter encapsulated by the mediastreamer2 library to capture the sound from the sound card, encode the sound and send it to the remote host through RTP. At the same time, it receives the RTP packet sent from the remote host and decodes it to the sound card for playback.

Filter graph:

Soundread-> EC-> encoder-> rtpsend

Rtprecv-> Decode-> dtmfgen-> EC-> soundwrite

2. Use the filter encapsulated by the mediastreamer2 library to capture the image from the camera, encode the image, and send it to the remote host through RTP (with local video preview). At the same time, it receives the RTP packet from the remote host, video Playback After decoding.

Filter graph:

Source-> pixconv-> tee-> encoder-> rtpsend

Tee-> output

Rtprecv-> decoder-> output

------------------------------------------------------------------------------

Program Command Parameters

Mediastream -- local <port> -- remote <IP: Port> -- payload <payload type number>

[-- Fmtp <fmtpline>] [-- jitter <miliseconds>]

Compile

# GCC mediastream. C-o mediastream-lmediastreamer-dvideo_enabled

 

Audio part:

PC1 IP: 192.168.1.44

PC2 IP: 192.168.1.45

PC1 #./mediastream -- local5010 -- remote 192.168.1.45: 6010 -- payload 110

PC2 #./mediastream -- local6010 -- remote 192.168.1.44: 5010 -- payload 110

110 refers to speex Speech Codec

 

Video Section:

PC1 #./mediastream -- local5010 -- remote 192.168.1.45: 6010 -- payload 102

PC2 #./mediastream -- local6010 -- remote 192.168.1.44: 5010 -- payload 102

Payload 102 refers to the h264 encoding/decoding method.

------------- The following red problem occurs ------------------------
Ortp-message-using permissive Algorithm
Ortp-error-videostream.c: no encoder available for payload 102: hashed.
Ortp-message-quality indicator:-1.000000

Solution: Compile and install msx264. Although x264 was installed before, mediastreamer2 does not know how to use x264. You must use msx264 to encapsulate x264 as an available mediastreamer2 interface.

Msx264: An H.264 plugin for mediastream2/Linphone

Final running result: the larger image Displays the remote image, and the smaller image in the lower right corner shows the local preview.

 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.