informasi kontak saya
Surat[email protected]
2024-07-12
한어Русский языкEnglishFrançaisIndonesianSanskrit日本語DeutschPortuguêsΕλληνικάespañolItalianoSuomalainenLatina
Saat kami membuat pemutar RTSP dan RTMP untuk platform Unity, beberapa perusahaan mengajukan persyaratan teknis tersebut, berharap dapat memutar streaming langsung panorama 8K RTSP|RTMP dan data 8K di headset, yang mengusulkan ide-ide baru untuk headset dan pemutar persyaratannya, kita akan membahas bagaimana perangkat VR yang dipasang di kepala memutar data streaming 8K RTSP|RTMP dari beberapa aspek:
Artikel ini mengambil modul pemutaran platform Android Unity3D RTSP|RTMP dari Daniu Live SDK sebagai contoh:
Mulai bermain:
- /*
- * SmartPlayerAndroidMono.cs
- * Author: daniusdk.com
- * QQ:89030985
- */
- public void Play()
- {
- if (is_running)
- {
- Debug.Log("已经在播放。。");
- return;
- }
-
- //获取输入框的url
- string url = input_url_.text.Trim();
-
- if (!url.StartsWith("rtmp://") && !url.StartsWith("rtsp://"))
- {
- videoUrl = "rtsp://admin:[email protected]:554/h264/ch1/main/av_stream";
- }
- else
- {
- videoUrl = url;
- }
-
- OpenPlayer();
-
- if ( player_handle_ == 0 )
- return;
-
- NT_U3D_Set_Game_Object(player_handle_, game_object_);
-
- /* ++ 播放前参数配置可加在此处 ++ */
- int is_using_tcp = 0; //TCP/UDP模式设置
- NT_U3D_SetRTSPTcpMode(player_handle_, is_using_tcp);
-
- int is_report = 0;
- int report_interval = 1;
- NT_U3D_SetReportDownloadSpeed(player_handle_, is_report, report_interval); //下载速度回调
-
- NT_U3D_SetBuffer(player_handle_, play_buffer_time_); //设置buffer time
-
- NT_U3D_SetPlayerLowLatencyMode(player_handle_, is_low_latency_ ? 1 : 0); //设置是否启用低延迟模式
-
- NT_U3D_SetMute(player_handle_, is_mute_ ? 1 : 0); //是否启动播放的时候静音
-
- NT_U3D_SetAudioVolume(player_handle_, cur_audio_volume_); //设置播放音量
-
- NT_U3D_SetVideoDecoderMode(player_handle_, is_hw_decode_ ? 1 : 0); //设置H.264软硬解模式
-
- NT_U3D_SetVideoHevcDecoderMode(player_handle_, is_hw_decode_ ? 1 : 0); //设置H.265软硬解模式
-
- int is_output = 1;
- int disable_use_image_planes = 0;
- bool is_supports_texture_format = SystemInfo.SupportsTextureFormat(TextureFormat.RG16);
- Debug.Log("is_supports_texture_format: " + is_supports_texture_format);
- int is_supported_multiple_format = is_supports_texture_format? 1:0;
- int max_images = 3;
- int buffer_pool_max_size = 0;
- NT_U3D_SetImageReaderOutput(player_handle_, is_output, disable_use_image_planes, is_supported_multiple_format, max_images, buffer_pool_max_size); //硬解码image reader
-
- int is_fast_startup = 1;
- NT_U3D_SetFastStartup(player_handle_, is_fast_startup); //设置快速启动模式
-
- int rtsp_timeout = 10;
- NT_U3D_SetRTSPTimeout(player_handle_, rtsp_timeout); //设置RTSP超时时间
-
- int is_auto_switch_tcp_udp = 1;
- NT_U3D_SetRTSPAutoSwitchTcpUdp(player_handle_, is_auto_switch_tcp_udp); //设置TCP/UDP模式自动切换
-
- int is_audiotrack = 1;
- NT_U3D_SetAudioOutputType(player_handle_, is_audiotrack); //设置音频输出模式: if 0: 自动选择; if with 1: audiotrack模式
-
- NT_U3D_SetUrl(player_handle_, videoUrl);
- /* -- 播放前参数配置可加在此处 -- */
-
- int flag = NT_U3D_StartPlay(player_handle_);
-
- if (flag == DANIULIVE_RETURN_OK)
- {
- is_need_get_frame_ = true;
- Debug.Log("播放成功");
- }
- else
- {
- is_need_get_frame_ = false;
- Debug.LogError("播放失败");
- }
-
- is_running = true;
- }
Implementasi OpenPlayer() yang sesuai adalah sebagai berikut:
- private void OpenPlayer()
- {
- if ( java_obj_cur_activity_ == null )
- {
- Debug.LogError("getApplicationContext is null");
- return;
- }
-
- player_handle_ = NT_U3D_Open();
-
- if (player_handle_ != 0)
- Debug.Log("open success");
- else
- Debug.LogError("open fail");
- }
Tutup Pemain:
- private void ClosePlayer()
- {
- is_need_get_frame_ = false;
- is_need_init_texture_ = false;
-
- int flag = NT_U3D_StopPlay(player_handle_);
- if (flag == DANIULIVE_RETURN_OK)
- {
- Debug.Log("停止成功");
- }
- else
- {
- Debug.LogError("停止失败");
- }
-
- flag = NT_U3D_Close(player_handle_);
- if (flag == DANIULIVE_RETURN_OK)
- {
- Debug.Log("关闭成功");
- }
- else
- {
- Debug.LogError("关闭失败");
- }
-
- player_handle_ = 0;
-
- NT_U3D_UnInit();
-
- is_running = false;
- video_format_ = VideoFrame.FORMAT_UNKNOWN;
- video_width_ = 0;
- video_height_ = 0;
- }
Perbarui data penyegaran:
- private void Update()
- {
- if (!is_need_get_frame_)
- return;
-
- if (player_handle_ == 0)
- return;
-
- AndroidJavaObject u3d_video_frame_obj = NT_U3D_GetVideoFrame(player_handle_);
-
- if (u3d_video_frame_obj == null)
- {
- return;
- }
-
- VideoFrame converted_video_frame = ConvertToVideoFrame(u3d_video_frame_obj);
-
- if (converted_video_frame == null)
- {
- u3d_video_frame_obj.Call("release");
-
- u3d_video_frame_obj = null;
- return;
- }
-
- if (!is_need_init_texture_)
- {
- if (converted_video_frame.format_ != video_format_)
- {
- is_need_init_texture_ = true;
-
- }
- else if (converted_video_frame.width_ != video_width_
- || converted_video_frame.height_ != video_height_
- || converted_video_frame.stride0_ != y_row_bytes_
- || converted_video_frame.stride1_ != u_row_bytes_
- || converted_video_frame.stride2_ != v_row_bytes_)
- {
- is_need_init_texture_ = true;
- }
- }
-
- if (is_need_init_texture_)
- {
- if (InitYUVTexture(converted_video_frame))
- {
- is_need_init_texture_ = false;
- }
- }
-
- UpdateYUVTexture(converted_video_frame);
-
- converted_video_frame.java_frame_obj_ = null;
- converted_video_frame = null;
- u3d_video_frame_obj.Call("release");
- u3d_video_frame_obj = null;
- }
Jika headset VR perlu memutar streaming 8K RTSP atau RTSP, headset tersebut memiliki persyaratan perangkat keras dan jaringan yang sangat tinggi, sehingga mungkin menghadapi beberapa tantangan dalam aplikasi praktis. Melalui pengujian sebenarnya, headset quest3, dikombinasikan dengan pemutar RTSP|RTMP kami, dapat mencapai penundaan pemutaran data video 8K tingkat milidetik di Unity untuk memenuhi skenario penggunaan dengan persyaratan waktu nyata yang sangat tinggi seperti kontrol keseimbangan dengan saya secara individu.