Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Lock mutex error #217

Open
GregCornis opened this issue Oct 25, 2024 · 7 comments
Open

Lock mutex error #217

GregCornis opened this issue Oct 25, 2024 · 7 comments

Comments

@GregCornis
Copy link

I'm trying to connect a Canon camera to a M350 via the PSDK. However, I'm struggling with the live view, with the following message

Encoding frame 5
Encoded with frameSize=34929
[21.517][utils]-[Error]-[DjiFlowController_SendData:330) mutex lock error
[21.517][channel]-[Error]-[DjiHighSpeedDataChannel_SendVideoStreamData:609) Send video stream error: 0x000000E3.
[21.517][user]-[Error]-[startMockLiveView:756) send video stream error: 0x000000E3.

I have the same error when I call DjiPayloadCamera_GetVideoStreamState

[47.718][channel]-[Error]-[DjiHighSpeedDataChannel_GetVideoStreamState:547) Lock mutex error.
[47.718][user]-[Info]-[startMockLiveView:715) Video state: busy 0 - 0 0 0

Here is basically the code that I'm running

// Task to send Live View data
void *startMockLiveView(void *ctx) {
  while (1) {
    // Get H264 NAL from somewhere else
    DjiPayloadCamera_SendVideoStream((const uint8_t *) nal->p_payload, size);
    usleep(100000);
  }
}


registerAbstractionHandlers();        // Register Osal & Nal & UART etc handlers 
DjiCore_Init(&userInfo);              // Correct info, the rest of the PSDK works,
DjiPayloadCamera_Init();
DjiPayloadCamera_RegCommonHandler(&mockHandler);
DjiCore_ApplicationStart();
T_DjiOsalHandler *handler = DjiPlatform_GetOsalHandler();
T_DjiTaskHandle *task;
handler->TaskCreate("liveview", startMockLiveView, 2048, NULL, task);

I'm seeing a similar issue in the PSDK demo :

[12.065][core]-[Info]-[DjiIdentityVerify_UpdatePolicy:482) Update dji sdk policy file successfully
[13.204][infor]-[Info]-[DjiAircraftInfo_GetAdapterSerialNumber:806) Get serial number of Skyport V2 or X-Port is 39CDKCS0010013
[13.205][core]-[Info]-[DjiCore_Init:174) Identify AircraftType = Matrice 350 RTK, MountPosition = Payload Port NO1, SdkAdapterType = Skyport V2
[13.387][time_sync]-[Info]-[DjiTimeSync_PushAppTimeHandle:111) Current time: 2024.10.25 17:45:55.
[22.391][cam]-[Error]-[DjiPayloadCamera_RegMediaDownloadPlaybackHandler:987) lock mutex error: 0x000000E3.
[22.391][user]-[Error]-[DjiTest_CameraEmuMediaStartService:199) psdk camera media function init error.
[22.391][user]-[Error]-[main:249) camera emu media init error

Do you know what is going wrong ? Thanks

@GregCornis
Copy link
Author

Edit : I've added

const T_DjiDataChannelBandwidthProportionOfHighspeedChannel bandwidthProportionOfHighspeedChannel =
        {10, 60, 30};
DjiHighSpeedDataChannel_SetBandwidthProportion(bandwidthProportionOfHighspeedChannel);

Now I don't have the warning anymore, and can successfully call DjiPayloadCamera_GetVideoStreamState. However no image is shown on DJI Pilot

@GregCornis
Copy link
Author

I've also tried to set the format to H264_CUSTOM but that fails, though I'm doing it before ApplicationStart()

[25.272][cam]-[Error]-[DjiPayloadCamera_SetVideoStreamType:799) remove negotiated device sync error: 0x000000E1.
[25.272][user]-[Error]-[main:1179) Set stream type error

I'm sending video as NAL decoded with libx264 (annex B enabled), so it should be spec-compliant.

@dji-dev
Copy link
Contributor

dji-dev commented Oct 28, 2024

Agent comment from Leon in Zendesk ticket #120335:

Hello, which version of PSDK are you using? If it is 3.9.1, it only supports setting DJI-H264 channel, but not Custom-H264. We suggest that you replace the H264 video file pushed in the sample to your own directory, use your code to push the sample file, and see if there is a black screen and whether it can be pushed successfully. This way, you can check whether there is a problem with your own code implementation.

°°°

@GregCornis
Copy link
Author

Ok I didn't know that (I don't think it's written in the docs). So what is DJI-H264 ? It looks like it's NAL H264 concatenated with audio ({0x00, 0x00, 0x00, 0x01, 0x09, 0x10}) .
Also, are there specific H264 parameters to use ? Here is what I'm using

    // x264 param
    x264_param_default_preset(&param, "ultrafast", NULL)
    param.i_bitdepth = 8;
    param.i_csp = X264_CSP_I422;
    param.b_vfr_input = 0;
    param.b_repeat_headers = 1;
    param.b_annexb = 1;
    param.i_bframe = 0;
    param.b_cabac = 0;
    param.b_deblocking_filter = 0;
    param.i_bframe_adaptive = 0;
    param.analyse.b_transform_8x8 = 0;
    param.analyse.i_me_method = X264_ME_DIA;
    param.analyse.i_trellis = 0;
    param.rc.b_mb_tree = 0;
    param.i_sync_lookahead = 0;
    param.rc.i_lookahead = 0;

@dji-dev
Copy link
Contributor

dji-dev commented Oct 30, 2024

Agent comment from Leon in Zendesk ticket #120335:

Hello, sorry, this is our oversight. We did not inform developers of this issue in advance or publicly. We are currently fixing it and will soon be able to use two channels of streaming separately. We have given the standards for video streaming in the document, which are for DJI format and Custom format respectively. You can check here:
https://developer.dji.com/doc/payload-sdk-tutorial/en/model-instruction/payload-develop-criterion.html#video-stream-transmission-standard
In the code, you only need to pay attention to the setting of the function:
DjiPayloadCamera_SetVideoStreamType(DJI_CAMERA_VIDEO_STREAM_TYPE_H264_DJI_FORMAT);
s_cameraVideoStreamType = DJI_CAMERA_VIDEO_STREAM_TYPE_H264_DJI_FORMAT;

°°°

@GregCornis
Copy link
Author

Hi, I can't manage to get it to work. I'm streaming the same video file as in your sample code (PSDK0005.h264), but somehow nothing is showing. I have set the format to DJI_FORMAT, and I'm sending the AUD frame after every NAL. Do you know if there is something missing ? I'm thinking maybe it's something related to the HighBandwithChannel, or some other configuration

@dji-dev
Copy link
Contributor

dji-dev commented Nov 7, 2024

Agent comment from Leon in Zendesk ticket #120335:

Hello, could you please provide us with the PSDK debug log for confirmation? Did your PSDK show any error message when the screen is black? We may be able to analyze and confirm from the error message.

°°°

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants