live5555 testProgs directory

test

testProgs

When there are many example programs involved, explaining each one can become very lengthy. However, I can provide you with a brief explanation of some key example programs to help you understand the purpose and functionality of each example:

  1. testOnDemandRTSPServer.cpp: Creates an RTSP server that allows on-demand (request play) streaming content.

  2. testRTSPClient.cpp: Implement RTSP client, request and play streaming media content from RTSP server.

  3. testRelay.cpp: Relay content from one RTSP streaming source server to another RTSP server.

  4. testReplicator.cpp: Creates a replication of streaming content, allowing multiple clients to access it simultaneously.

  5. testMP3Streamer.cpp: Stream MP3 audio content.

  6. testMPEG4VideoStreamer.cpp: Stream MPEG-4 video.

  7. testH264VideoStreamer.cpp/testH265VideoStreamer.cpp: Stream H.264/H.265 video.

  8. testGSMStreamer.cpp: Stream GSM audio.

  9. testWAVAudioStreamer.cpp: Streams WAV audio.

  10. testMPEG2TransportStreamer.cpp: Streams MPEG-2 transport stream.

  11. testDVVideoStreamer.cpp: Stream DV video.

  12. testOggStreamer.cpp: Stream Ogg audio.

  13. testH264VideoToTransportStream.cpp/testH265VideoToTransportStream.cpp: Convert H.264/H.265 video to transport stream.

  14. testMPEG2TransportStreamTrickPlay.cpp: realizes the fast forward and rewind functions of MPEG-2 transport stream.

  15. testMKVStreamer.cpp/testMKVSplitter.cpp: Streams and splits MKV file content.

  16. testMPEG1or2VideoStreamer.cpp / testMPEG1or2AudioVideoStreamer.cpp: Stream MPEG-1/MPEG-2 video.

Each sample program represents a use case of the Live555 library, covering different audio and video processing and transmission scenarios. You can choose the appropriate sample program according to your needs, and learn how to use the Live555 library to implement specific functions by reading the code and comments. If you have more specific questions, feel free to ask.

video streaming

Modifying testOnDemandRTSPServerthe sample program to suit your needs requires making some changes in the source code. The following is a rough step for your reference:

  1. Find the sample program source file: In the source code directory of Live555, enter testProgsthe folder and you will find testOnDemandRTSPServerthe source code file, usually named testOnDemandRTSPServer.cpp.

  2. Open the source file for editing: Using a text editor (such as Text Editor, Visual Studio Code, Sublime Text, etc.), open testOnDemandRTSPServer.cppthe file.

  3. Set the video file path: In the source file, you will find lines of code similar to the following:

      // A MPEG-4 video elementary stream:
      {
          
          
        char const* streamName = "mpeg4ESVideoTest";
        char const* inputFileName = "test.m4e";
        ServerMediaSession* sms
          = ServerMediaSession::createNew(*env, streamName, streamName,
    				      descriptionString);
        sms->addSubsession(MPEG4VideoFileServerMediaSubsession
    		       ::createNew(*env, inputFileName, reuseFirstSource));
        rtspServer->addServerMediaSession(sms);
    
        announceStream(rtspServer, sms, streamName, inputFileName);
      }
    

    Change test.m4e to the path of your actual video file, for example "path/to/your/video.mp4".

  4. Set the listening port: In the source file, you will find lines similar to the following:

    // Set up the RTSP server:
      RTSPServer* rtspServer = RTSPServer::createNew(*env, 8554, authDB);
    

    Change 8554to the listening port number you want.

  5. Save modifications and compile: Save the modifications to the source file and compile using the Makefile provided by Live555. In the root directory of Live555, use makethe command to compile the sample program and generate an executable file.

  6. Run RTSP server: Run the compiled testOnDemandRTSPServerexecutable file to start the RTSP server.

  7. Client-side playback stream: In another terminal, you can use testRTSPClientthe sample program provided by Live555, specify the server address, port and stream name, request and play the stream from the server.

live streaming

Notice:

FFmpeg is required to encode and decode videos.

Yes, you understand correctly. To receive a real-time stream from an RTSP source server and redistribute it to the client, two RTSP servers need to be set up, one as the source server and the other as the forwarding server. Here are the detailed steps:

  1. Prepare the Live555 library: Make sure you have the Live555 library compiled and ready to use.

  2. Create a source RTSP server: Found in Live555's sample program testOnDemandRTSPServer, this program can create an RTSP server for hosting live streams.

  3. Modify the source server: In testOnDemandRTSPServerthe sample program, modify the server settings according to your needs, such as selecting the appropriate port, file path, SDP information, etc.

  4. Run the source server: Compile and run the modified testOnDemandRTSPServersample program, start the source RTSP server, and start sending the real-time stream.

  5. Create a forwarding RTSP server: Found in Live555's sample program testRTSPServer, this program can create another RTSP server for receiving the live stream from the source server and forwarding it.

  6. Modify the forwarding server: In testRTSPServerthe sample program, modify the server settings to listen on the appropriate port.

  7. Add forwarding logic: In testRTSPServerthe source code of , you need to write the logic to receive the live stream from the source RTSP server and redistribute it to the client. This involves taking live streaming data from the origin server, packaging it into RTP packets, and transmitting it to the client.

  8. Run the forwarding server: Compile and run the modified testRTSPServersample program to start the forwarding RTSP server.

  9. Client-side playback stream: Use an RTSP client to connect to the forwarding server, request and play the live stream from the source server.

Guess you like

Origin blog.csdn.net/qq_45865950/article/details/132689236