but i need to send the data using UDP protocol , please tell me how I can convert the RTPStream to under layer and then retrieve the stream to upper layer at the receiver side ?!?
The code is :
public SessionManager Videomanger, Audiomanger;
// we need to creat two RTP sesion one for audio and one for video
int RTPport = 1990;
int RTCPport = 1989;
RTPStream stream;
Processor processor;
int i=0;
public long SSRC = 15;
SourceDescription [] srcdesc;
double rtcp_bw_fraction = 0.2;
double rtcp_sender_bw_fraction = 0.2;
public static final int DES = 1;
byte[] key;
EncryptionInfo encrpt = new EncryptionInfo(DES,key);
//SendStream represents a stream of data coming from the Processor or
// input DataSource that is being sent over the network.
//To create a new SendStream, you
//call the SessionManager createSendStream method.
InetAddress add ;
SendStream snd;
int TTL = 100;
SessionAddress sessionAdd = new SessionAddress(add, 1989,TTL);
//For ReceiveStreams,
// this DataSource is always a PushBufferDataSource.
ReceiveStream rcv; //represents a stream thatŐs being received from a remote participant.
DataSource datasrc = null;
Participant parti; // interface to track and mange all paticipants
Buffer getFlags;
byte [] payload;
String RTPstr;
// RTPSocket rtps;
int payloadType, sequenceNumber;
long timestamp;
RTPHeader header;
// header parameter
// boolean extenstion = false;
public int marker = 0; // extention type
// buffere data source associated with RTP streams
PushBufferDataSource databuffer;
// our main rtpsocket abstraction to which we will create and send
// to the Manager for appropriate handler creation
RTPSocket rtpsocket = null;
// the control RTPIODataSource of the RTPSocket above
RTPPushDataSource rtcpsource = null;
public void sendRTP() throws IOException{
// all variables should be defined global
// Create a SessionManager and hand over the
// datasource for SendStream creation.
Videomanger = new com.sun.media.rtp.RTPSessionMgr();
try {
// initialize session manger
Videomanger.initSession(sessionAdd, SSRC, srcdesc, rtcp_bw_fraction, rtcp_sender_bw_fraction);
} catch (InvalidSessionAddressException ex) {
Logger.getLogger(Client2View.class.getName()).log(Level.SEVERE, null, ex);
}
try {
Videomanger.startSession(sessionAdd, TTL, encrpt);
} catch (InvalidSessionAddressException ex) {
Logger.getLogger(Client2View.class.getName()).log(Level.SEVERE, null, ex);
}
rtcpsource = rtpsocket.getControlChannel();
//after Construct a Processor using the appropriate capture DataSource.
/// this to retrive data from the processor
datasrc = (DataSource) processor.getDataOutput();
// creat RTP packet to send data
stream = (RTPStream) datasrc;
// we need to convert rtp streams to string then to byte for underlayer
RTPstr = stream.toString();
payload = RTPstr.getBytes();
header = new RTPHeader(marker);
InetAddress host = InetAddress.getByName(ipaddress);
DatagramPacket packet = new DatagramPacket(payload, payload.length,host,portnumber) ;
DatagramSocket socket = new DatagramSocket();
socket.send(packet);
// after this .. socket creation ,,,
} /// end sendRTP
This post has been edited by macosxnerd101: 25 March 2011 - 03:48 PM
Reason for edit:: Please use code tags

New Topic/Question
Reply



MultiQuote

|