|
How to buffering RTSP live data?
|
10/01/2024 4:15 AM
post122609
|
How to buffering RTSP live data?
I am trying to play live RTSP data on QNX Neutrino OS. I have created C code to do this and it works. I have connected
my development kit and PC via ethernet. I can play RTSP video streamed from PC on my development kit but the first image
is always distorted. The video is distorted for about 3-4 seconds on the screen.
My stream code in PC:
```
cvlc -vvv ~/Videos/bbb_sunflower_1080p_60fps_normal.mp4 --sout '#transcode{acodec=mp4a}:rtp{sdp=rtsp://:8554/stream}' :
network-caching=1500
```
My C code in Development Kit(Plays video during 60 sec.):
```
#include <screen/screen.h>
#include <mm/renderer.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <unistd.h>
#include <sys/select.h>
#include <fcntl.h>
#define WINGRP_NAME_MAX_LEN 128
// I/O devices
static const char *video_device_url = "screen:?winid=videosamplewindowgroup&wingrp=videosamplewindowgroup";
static const char *audio_device_url = "audio:default";
// Name of video context
static const char *video_context_name = "samplevideocontextname";
// Window group name
static const char *window_group_name = "videosamplewindowgroup";
// Window Name
const char *window_name = "appwindow";
strm_dict_t* calculate_rect(int width, int height) {
const int image_width = 640;
const int image_height = 480;
const float image_aspect = (float)image_width / (float)image_height;
const float aspect_tolerance = 0.1;
char buffer[16];
strm_dict_t *dict = strm_dict_new();
if (NULL == dict) {
return NULL;
}
//fullscreen is the default.
dict = strm_dict_set(dict, "video_dest_x", "0");
if (NULL == dict)
goto fail;
dict = strm_dict_set(dict, "video_dest_y", "0");
if (NULL == dict)
goto fail;
dict = strm_dict_set(dict, "video_dest_w", itoa(width, buffer, 10));
if (NULL == dict)
goto fail;
dict = strm_dict_set(dict, "video_dest_h", itoa(height, buffer, 10));
if (NULL == dict)
goto fail;
float screen_aspect = (float)width/(float)height;
dict = strm_dict_set(dict, "video_dest_x", itoa((width - image_width) / 2, buffer, 10));
if (NULL == dict)
goto fail;
width = height * image_aspect;
dict = strm_dict_set(dict, "video_dest_w", itoa(width, buffer, 10));
if (NULL == dict)
goto fail;
return dict;
fail:
strm_dict_destroy(dict);
return NULL;
}
int main(void) {
int rc;
int exit_application = 0;
printf("DBG-1\n");
// Screen variables
screen_context_t screen_context = 0;
screen_window_t screen_window = 0;
int screen_size[2] = {0,0};
// Renderer variables
mmr_connection_t* mmr_connection = 0;
mmr_context_t* mmr_context = 0;
strm_dict_t* dict = NULL;
// I/O variables
int video_device_output_id = -1;
int audio_device_output_id = -1;
printf("DBG-2\n");
/*
* Create the window used for video output.
*/
if (screen_create_context(&screen_context, SCREEN_APPLICATION_CONTEXT) != 0) {
return EXIT_FAILURE;
}
printf("DBG-3\n");
if (screen_create_window(&screen_window, screen_context) != 0) {
screen_destroy_context(screen_context);
return EXIT_FAILURE;
}
printf("DBG-4\n");
if (screen_create_window_group(screen_window, window_group_name) != 0) {
return EXIT_FAILURE;
}
printf("DBG-5\n");
int format = SCREEN_FORMAT_RGBA8888;
if (screen_set_window_property_iv(screen_window, SCREEN_PROPERTY_FORMAT, &format) != 0) {
return EXIT_FAILURE;
}
if(screen_set_window_property_cv(screen_window, SCREEN_PROPERTY_ID_STRING, 32,...
View Full Message
|
|
|