当前位置: 编程技术>移动开发
本页文章导读:
▪战神传言 战神传说
鸟哥,鸟哥的第一款拙作,动作游戏:战神传说之决战金字塔,由于是第一个作品,上线后游戏收入水平一般。如果有玩家有玩,感谢你的支持,有什么评论,请不客气的提,谢谢.........
▪ live555代码解读之三:SETUP跟PLAY请求消息处理过程 live555代码解读之三:SETUP和PLAY请求消息处理过程
SETUP请求消息处理过程 前面已经提到RTSPClientSession类,用于处理单独的客户会话。其类成员函数handleCmd_SETUP()处理客户端的SETUP请.........
▪ FileConnection访问本土文件系统 FileConnection访问本地文件系统
FC api是JSR 75, PDA Optional Packages for the J2ME Platform的一部分,用于访问本地文件系统。
FC api通过Generic Connection Framework(GCF)访问文件系统,允许访问包括存储卡在内的.........
[1]战神传言
来源: 互联网 发布时间: 2014-02-18
战神传说
鸟哥,鸟哥的第一款拙作,动作游戏:
战神传说之决战金字塔,由于是第一个作品,上线后游戏收入水平一般。如果有玩家有玩,感谢你的支持,有什么评论,请不客气的提,谢谢!
客气!
鸟哥,鸟哥的第一款拙作,动作游戏:
战神传说之决战金字塔,由于是第一个作品,上线后游戏收入水平一般。如果有玩家有玩,感谢你的支持,有什么评论,请不客气的提,谢谢!
1 楼
shizhiwu
2010-03-04
向你学习,我也在这方面努力着...
2 楼
鸟哥哥
2010-03-04
shizhiwu 写道
向你学习,我也在这方面努力着...
客气!
[2] live555代码解读之三:SETUP跟PLAY请求消息处理过程
来源: 互联网 发布时间: 2014-02-18
live555代码解读之三:SETUP和PLAY请求消息处理过程
SETUP请求消息处理过程
前面已经提到RTSPClientSession类,用于处理单独的客户会话。其类成员函数handleCmd_SETUP()处理客户端的SETUP请求。调用parseTransportHeader()对SETUP请求的传输头解析,调用子会话(这里具体实现类为 OnDemandServerMediaSubsession)的getStreamParameters()函数获取流媒体发送传输参数。将这些参数组装成响应消息,返回给客户端。
获取发送传输参数的过程:调用子会话(具体实现类MPEG1or2DemuxedServerMediaSubsession)的 createNewStreamSource(...)创建MPEG1or2VideoStreamFramer,选择发送传输参数,并调用子会话的 createNewRTPSink(...)创建MPEG1or2VideoRTPSink。同时将这些信息保存在StreamState类对象中,用于记录流的状态。
客户端发送两个SETUP请求,分别用于建立音频和视频的RTP接收。
PLAY请求消息处理过程
RTSPClientSession类成员函数handleCmd_PLAY()处理客户端的播放请求。首先调用子会话的startStream(),内部调用MediaSink::startPlaying(...),然后是 MultiFramedRTPSink::continuePlaying(),接着调用 MultiFramedRTPSink::buildAndSendPacket(...)。buildAndSendPacke内部先设置RTP包头,内部再调用MultiFramedRTPSink::packFrame()填充编码帧数据。
packFrame内部通过 FramedSource::getNextFrame(), 接着MPEGVideoStreamFramer::doGetNextFrame(),再接着经过 MPEGVideoStreamFramer::continueReadProcessing(), FramedSource::afterGetting(...), MultiFramedRTPSink::afterGettingFrame(...), MultiFramedRTPSink::afterGettingFrame1(...)等一系列繁琐调用,最后到了 MultiFramedRTPSink::sendPacketIfNecessary(), 这里才真正发送RTP数据包。然后是计算下一个数据包发送时间,把MultiFramedRTPSink::sendNext(...)函数句柄传给任务调度器,作为一个延时事件调度。在主循环中,当MultiFramedRTPSink::sendNext()被调度时,又开始调用 MultiFramedRTPSink::buildAndSendPacket(...)开始新的发送数据过程,这样客户端可以源源不断的收到服务器传来的RTP包了。
发送RTP数据包的间隔计算方法:
Update the time at which the next packet should be sent, based on the duration of the frame that we just packed into it.
涉及到一些类有:
MPEGVideoStreamFramer: A filter that breaks up an MPEG video elementary stream into headers and frames
MPEG1or2VideoStreamFramer: A filter that breaks up an MPEG 1 or 2 video elementary stream into frames for: Video_Sequence_Header, GOP_Header, Picture_Header
MPEG1or2DemuxedElementaryStream: A MPEG 1 or 2 Elementary Stream, demultiplexed from a Program Stream
MPEG1or2Demux: Demultiplexer for a MPEG 1 or 2 Program Stream
ByteStreamFileSource: A file source that is a plain byte stream (rather than frames)
MPEGProgramStreamParser: Class for parsing MPEG program stream
StreamParser: Abstract class for parsing a byte stream
StreamState:A class that represents the state of an ongoing stream
SETUP请求消息处理过程
前面已经提到RTSPClientSession类,用于处理单独的客户会话。其类成员函数handleCmd_SETUP()处理客户端的SETUP请求。调用parseTransportHeader()对SETUP请求的传输头解析,调用子会话(这里具体实现类为 OnDemandServerMediaSubsession)的getStreamParameters()函数获取流媒体发送传输参数。将这些参数组装成响应消息,返回给客户端。
获取发送传输参数的过程:调用子会话(具体实现类MPEG1or2DemuxedServerMediaSubsession)的 createNewStreamSource(...)创建MPEG1or2VideoStreamFramer,选择发送传输参数,并调用子会话的 createNewRTPSink(...)创建MPEG1or2VideoRTPSink。同时将这些信息保存在StreamState类对象中,用于记录流的状态。
客户端发送两个SETUP请求,分别用于建立音频和视频的RTP接收。
PLAY请求消息处理过程
RTSPClientSession类成员函数handleCmd_PLAY()处理客户端的播放请求。首先调用子会话的startStream(),内部调用MediaSink::startPlaying(...),然后是 MultiFramedRTPSink::continuePlaying(),接着调用 MultiFramedRTPSink::buildAndSendPacket(...)。buildAndSendPacke内部先设置RTP包头,内部再调用MultiFramedRTPSink::packFrame()填充编码帧数据。
packFrame内部通过 FramedSource::getNextFrame(), 接着MPEGVideoStreamFramer::doGetNextFrame(),再接着经过 MPEGVideoStreamFramer::continueReadProcessing(), FramedSource::afterGetting(...), MultiFramedRTPSink::afterGettingFrame(...), MultiFramedRTPSink::afterGettingFrame1(...)等一系列繁琐调用,最后到了 MultiFramedRTPSink::sendPacketIfNecessary(), 这里才真正发送RTP数据包。然后是计算下一个数据包发送时间,把MultiFramedRTPSink::sendNext(...)函数句柄传给任务调度器,作为一个延时事件调度。在主循环中,当MultiFramedRTPSink::sendNext()被调度时,又开始调用 MultiFramedRTPSink::buildAndSendPacket(...)开始新的发送数据过程,这样客户端可以源源不断的收到服务器传来的RTP包了。
发送RTP数据包的间隔计算方法:
Update the time at which the next packet should be sent, based on the duration of the frame that we just packed into it.
涉及到一些类有:
MPEGVideoStreamFramer: A filter that breaks up an MPEG video elementary stream into headers and frames
MPEG1or2VideoStreamFramer: A filter that breaks up an MPEG 1 or 2 video elementary stream into frames for: Video_Sequence_Header, GOP_Header, Picture_Header
MPEG1or2DemuxedElementaryStream: A MPEG 1 or 2 Elementary Stream, demultiplexed from a Program Stream
MPEG1or2Demux: Demultiplexer for a MPEG 1 or 2 Program Stream
ByteStreamFileSource: A file source that is a plain byte stream (rather than frames)
MPEGProgramStreamParser: Class for parsing MPEG program stream
StreamParser: Abstract class for parsing a byte stream
StreamState:A class that represents the state of an ongoing stream
[3] FileConnection访问本土文件系统
来源: 互联网 发布时间: 2014-02-18
FileConnection访问本地文件系统
FC api是JSR 75, PDA Optional Packages for the J2ME Platform的一部分,用于访问本地文件系统。
FC api通过Generic Connection Framework(GCF)访问文件系统,允许访问包括存储卡在内的文件系统。
包括如下两个接口和三个类:
FileConnection 访问文件和文件夹的接口。
FileSystemListener 添加删除根目录文件系统的状态监听的接口。
FileSystemRegistry 添加删除根目录文件系统的接口注册类。
ConnectionClosedException 当一个文件句柄的操作被调用,而文件已经被关闭时抛出的异常。
IllegalModeException 当操作所对应的模式不被文件打开模式支持时抛出的异常。
判断是否支持FC: 引用文字
if(System.getProperty("microedition.io.file.FileConnection.version") != null){ // file.separator
// FCOP available
} else {
// FCOP not available
}
打开文件:// CFCard/:
FileConnection fc = (FileConnection) Connector.open("file:///CFCard/");
// SDCard/:
FileConnection fc = (FileConnection) Connector.open("file:///SDCard/");
// MemoryStick/:
FileConnection fc = (FileConnection) Connector.open("file:///MemoryStick/");
// C:/:
FileConnection fc = (FileConnection) Connector.open("file:///C:/");
// / File:
Connection fc = (FileConnection) Connector.open(file:////);
只读方式打开一个文件: String url = "file:///data.txt";
InputConnection conn = null;
int mode = Connector.READ_ONLY;
try {
conn =(InputConnection) Connector.open( url, mode );
// Always check whether the file or directory exists.
// Create the file if it doesn't exist.
if(!conn.exists()) {
}
} catch( IOException ioe ){
// no file
}
创建一个文件:
String url = "file:///SDCard/data.txt";
FileConnection conn = null;
int mode = Connector.WRITE_ONLY;
try {
conn = (FileConnection)Connector.open(url, mode);
if(filecon.create()){ // create the file
OutputStream out = conn.openOutputStream();
// now write data to the file
}
conn.close();
} catch(IOException e){
// error
} catch(SecurityException e){
// no permission to create/write
}
列举一个目录下的文件:// FileConnection.list(String filter, boolean includeHidden)
String url = "file:///C:/";
FileConnection conn = null;
try {
conn = (FileConnection) Connector.open(url);
if( conn.isDirectory() ) {
Enumeration names = conn.list();
while( names.hasMoreElements() ){
String name = (String) e.nextElement();
// do something
}
} else {
// not a directory!
}
} catch(IOException e) {
// could not access the URL
} catch(SecurityException e) {
// no permission to read the directory
}
读取文件内容:String url = "file:///CFCard/data.txt";
InputConnection conn = null;
int mode = Connector.READ_ONLY;
try {
FileConnection fc = (FileConnection)Connector.open(url, mode);
if(!fc.exists()) {
throw new IOException("File does not exist");
}
InputStream is = fc.openInputStream();
byte b[] = new byte[1024];
int length = is.read(b, 0, 1024);
System.out.println("Content of "+fileName + ": "+ new String(b, 0, length));
} catch (Exception e) {
}
最新技术文章: