bytearray - RTSP Programming with Java. How to read single part frames? -


i trying implement rtsp server java fun.

since not have pre-knowledge rtsp. starting analysis made source code.

i found code in internet.

link :

http://nsl.cs.sfu.ca/teaching/09/820/streaming/client.html http://nsl.cs.sfu.ca/teaching/09/820/streaming/server.html http://nsl.cs.sfu.ca/teaching/09/820/streaming/videostream.html http://nsl.cs.sfu.ca/teaching/09/820/streaming/rtppacket.html

for posting, got question videostream.java.

it has method below :

 public int getnextframe(byte[] frame) throws exception   {     int length = 0;     string length_string;     byte[] frame_length = new byte[5];      //read current frame length     fis.read(frame_length,0,5);      //transform frame_length integer     length_string = new string(frame_length);     length = integer.parseint(length_string);      return(fis.read(frame,0,length));   } 

as can see, casts byte[] string integer. however, in experience, string turns out hexa string. changed like... below.

integer.parseint(length_string.trim(), 16);

it looks ok sometimes, gets number format exception. when print length_string variables, show in console iso2a, vc1mp, 41��� ....

i can not know missing here. can explain purpose of codes here?

length_string = new string(frame_length); length = integer.parseint(length_string); 

p.s

is there knows full implementation of these code or other samples not uses third party libs, me.

i answer myself close question.

each video types has own data structure.

in case, set data type 'mjpeg', load 'mpeg' file.

so bytes array appears weird way.

  • fyi, mjpeg pack of jpeg. every frame key frame.
  • other type handled before, instance, ts file, has i-frames , b-frames. former 1 has clear image since key frame. second 1 looks broken since not key frame.

Comments

Popular posts from this blog

c++ - Delete matches in OpenCV (Keypoints and descriptors) -

java - Could not locate OpenAL library -

sorting - opencl Bitonic sort with 64 bits keys -