我正在使用mjsip sip堆栈进行软件电话项目.Mjsip仅支持g711或PCMA/PCMU编解码器.我已将G729添加到我的项目中.当我构建项目时,它没有显示错误.但是当手机连接时,呼叫建立,没有语音传输,实际上我的应用程序不生成任何rtp数据包.并在日志中显示错误
java.lang.NullPointerException
RtpStreamReceiver - run -> Terminated.
at local.media.RtpStreamReceiver.run(RtpStreamReceiver.java:171)
Run Code Online (Sandbox Code Playgroud)
我没找到错误.
这是我的RtpStreamReceiver.java类.
package local.media;
import local.net.RtpPacket;
import local.net.RtpSocket;
import java.io.*;
import java.net.DatagramSocket;
import org.flamma.codec.SIPCodec;
/** RtpStreamReceiver is a generic stream receiver.
* It receives packets from RTP and writes them into an OutputStream.
*/
public class RtpStreamReceiver extends Thread {
public static int RTP_HEADER_SIZE = 12;
private long start = System.currentTimeMillis();
public static final int SO_TIMEOUT = 200; // Maximum blocking time, spent waiting for reading new bytes [milliseconds]
private …
Run Code Online (Sandbox Code Playgroud) 我是Android和套接字编程的新手.我想创建一个Android应用程序,将视频从设备相机实时传输到PC.我首先要做的是从PreviewCallback参数获取原始视频数据并将其转换为RTP数据包.我只是使用JLibRTP来做到这一点.关于传输数据包我认为,有一些相关的类:RtpPkt,RtpSession和RtpSocket.
这是我的一瞥代码:
DatagramSocket rtpSocket = new DatagramSocket();
DatagramSocket rtcpSocket = new new DatagramSocket();
RtpSession rtpSession = new RtpSession(rtpSocket, rtcpSocket);
public void surfaceCreated(SurfaceHolder holder) {
try {
camera = Camera.open();
camera.setPreviewCallback(new PreviewCallback() {
public void onPreviewFrame(byte[] _data, Camera _camera) {
int height = 240;
try {
rtps.sendData(_data);
} catch (Exception e) {
e.printStackTrace();
Toast.makeText(getApplicationContext(), e.toString(),
Toast.LENGTH_SHORT).show();
}
}
});
camera.setPreviewDisplay(holder);
camera.startPreview();
} catch (IOException e) {
Log.d("CAMERA", e.getMessage());
}
}
Run Code Online (Sandbox Code Playgroud)
我仍然想知道我必须在哪里放置地址和端口信息.我知道上面的代码仍然需要你修改任何主人.谢谢你提前..
我想编写一个Android应用程序,用于将相机流式传输到PC(H.263,MPEG_4).我发现了一些库:sipandroid,jlibrtp.SIPandroid:RTP数据包是流式传输的(wireshark在PC上很好地捕获它),但是VLC无法播放它.
Jlibrtp:API很阴暗,使用VLC无法正确播放流.
可能是对这些库进行了一些调整(使其适用于相机流),还是有一些其他库具有干净的API和样本?
感谢您的回答.
我有一个RTP Stream插槽,接收来自三星网络摄像机的JPEG流.
我不太了解JPEG格式的工作原理,但我知道这个传入的JFIF或JPEG流给了我JPEG头
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Type-specific | Fragment Offset |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Type | Q | Width | Height |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
and then
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Restart Interval |F|L| Restart Count |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
and then in the first packet, there is this header
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| MBZ | Precision | Length |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Quantization Table Data |
| ... |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
Run Code Online (Sandbox Code Playgroud)
我想我正确地解析了它们,这是一段代码,我如何存储一个JPEG Stream数据包.
int extraOff=0;
public bool Decode(byte* data, int offset)
{
if (_initialized == false)
{
type_specific = data[offset + …
Run Code Online (Sandbox Code Playgroud) 我正在使用Mjsip来创建一个软电话.在代码中有三种类型的音频分层选项.
我没有使用RAT.它的价值被我自己弄错了.这是调用JMF的代码:
public JMFAudioLauncher(int local_port, String remote_addr, int remote_port, int direction, Log logger)
{
log=logger;
localport=local_port;
remoteport=remote_port;
remoteaddr=remote_addr;
// Patch for working with JMF with local streams
if (remote_addr.startsWith("127."))
{
printLog("Patch for JMF: replaced local destination address "+remote_addr+" with 255.255.255.255");
remote_addr="255.255.255.255";
}
dir=direction;
if (dir>=0) sender=new JMediaSender("audio",null,remote_addr,remote_port);
if (dir<=0) receiver=new JMediaReceiver("audio",local_port,null);
}
/** Starts media application */
public boolean startMedia()
{
printLog("launching JMF-Audio...");
String err1=null, err2=null;
if (sender!=null) err1=sender.start();
if (err1!=null) printLog("Error trying to send …
Run Code Online (Sandbox Code Playgroud) 我正在尝试从Android手机中传输视频,应该在媒体播放器中观看.我一直在寻找http://www.mattakis.com/blog/kisg/20090708/broadcasting-video-with-android-without-writing-to-the-file-system,这似乎是一个死胡同,因为它发送原始文件数据,而不是可流式格式.
然后我尝试使用SipDroid中的一些代码,更具体; VideoCamera.java,RtpPacket.java和RtpSocket.java的部分,它们在UDP上提供流,但是这些在mplayer中无法播放(无法检测编解码器).Wireshark告诉它是一个UDP数据包而不是RTP数据包,所以可能会丢失一些东西?
我有点卡住,你有什么建议如何超越这个颠簸?
环境:
我有一台IP摄像机,能够通过RTP以H.264编码格式传输数据.从以太网记录该原始流.有了这些数据,我必须工作.
目标:
最后我想要一个*.mp4文件,我可以使用常见的媒体播放器(如VLC或Windows MP).
到目前为止我做了什么:
我拿了原始流数据并解析它.由于数据是通过RTP传输的,我需要处理NAL字节,SPS和PPS.
1.写一个原始文件
首先,我确定通过以太网接收的每个帧的类型.为此,我解析每个RTP有效负载的前两个字节,因此我可以获得8个NAL单元位,片段类型位以及开始,保留和结束位.在有效载荷中,它们的排列方式如下:
Byte 1: [ 3 NAL Unit Bits | 5 Fragment Type Bits]
Byte 2: [Start Bit | Reserved Bit | End Bit | 5 NAL Unit Bits]
Run Code Online (Sandbox Code Playgroud)
由此我可以确定:
在我的案例中必要的片段类型是:
Fragment Type 7 = SPS
Fragment Type 8 = PPS
Fragment Type 28 = Video Fragment
Run Code Online (Sandbox Code Playgroud)
通过将字节1和2中的NAL单元位放在一起来创建NAL字节.
现在,根据碎片类型,我执行以下操作:
SPS/PPS:
0x00 0x00 0x01
),然后写入SPS或PPS数据使用起始位进行分段
没有Start Bit的碎片
这意味着我的原始文件看起来像这样:
[NAL Prefix][SPS][NAL …
Run Code Online (Sandbox Code Playgroud) 我需要捕获SIP和RTP流量以发现问题.我可以很好地捕获SIP消息,但是捕获RTP流量时遇到问题.
我尝试了以下但是这只是取出SIP包而没有RTP.
tcpdump -T rtp -vvv src -s 1500 -i any -w /home/lantrace_test2.pcap port 5060
我想这样做的另一种方式是rtp使用一系列UDP端口,捕获我们用于RTP流量的范围,但我找不到捕获一系列端口的方法,因此不确定tcpdump是否支持捕获端口范围
感谢您的任何帮助,您可以提供
我是gstreamer的新手,我正在尝试使用它.我的第一个目标是在两个设备之间创建一个简单的rtp h2p视频流.我正在使用这两个管道:
发件人: gst-launch-1.0 -v filesrc location=c:\\tmp\\sample_h264.mov ! x264enc ! rtph264pay ! udpsink host=127.0.0.1 port=5000
接收器:
gst-launch-1.0 -v udpsrc port=5000 ! rtpmp2tdepay ! decodebin ! autovideosink
但是对于第一个(发件人),我收到以下错误:
Setting pipeline to PAUSED ...
Pipeline is PE*R*O L(LgIsNtG- l.a.u.n
h-1.0:5788): CRITICAL **: gst_adapter_map: assertion `size > 0' failed
ERROR: from element /GstPipeline:pipeline0/GstFileSrc:filesrc0: Internal data flow error.
Additional debug info:
gstbasesrc.c(2812): gst_base_src_loop (): /GstPipeline:pipeline0/GstFileSrc:filesrc0:
streaming task paused, reason not-negotiated (-4)
ERROR: pipeline doesn't want to preroll.
Setting pipeline to NULL ...
Freeing pipeline …
Run Code Online (Sandbox Code Playgroud)