Skip to content

Commit

Permalink
AP_Camera: Use AP_MAVLINK_MSG_VIDEO_STREAM_INFORMATION_ENABLED guard
Browse files Browse the repository at this point in the history
  • Loading branch information
nexton-winjeel committed Jul 25, 2024
1 parent 112184d commit 8403ca8
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 0 deletions.
4 changes: 4 additions & 0 deletions libraries/AP_Camera/AP_Camera.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -462,10 +462,12 @@ bool AP_Camera::send_mavlink_message(GCS_MAVLINK &link, const enum ap_message ms
CHECK_PAYLOAD_SIZE2(CAMERA_CAPTURE_STATUS);
send_camera_capture_status(chan);
break;
#if AP_MAVLINK_MSG_VIDEO_STREAM_INFORMATION_ENABLED
case MSG_VIDEO_STREAM_INFO:
CHECK_PAYLOAD_SIZE2(VIDEO_STREAM_INFORMATION);
send_video_stream_information(chan);
break;
#endif

default:
// should not reach this; should only be called for specific IDs
Expand Down Expand Up @@ -620,6 +622,7 @@ void AP_Camera::send_camera_capture_status(mavlink_channel_t chan)
}
}

#if AP_MAVLINK_MSG_VIDEO_STREAM_INFORMATION_ENABLED
// send video stream information message to GCS
void AP_Camera::send_video_stream_information(mavlink_channel_t chan)
{
Expand All @@ -632,6 +635,7 @@ void AP_Camera::send_video_stream_information(mavlink_channel_t chan)
}
}
}
#endif // AP_MAVLINK_MSG_VIDEO_STREAM_INFORMATION_ENABLED

/*
update; triggers by distance moved and camera trigger
Expand Down
2 changes: 2 additions & 0 deletions libraries/AP_Camera/AP_Camera.h
Original file line number Diff line number Diff line change
Expand Up @@ -237,8 +237,10 @@ class AP_Camera {
// send camera capture status message to GCS
void send_camera_capture_status(mavlink_channel_t chan);

#if AP_MAVLINK_MSG_VIDEO_STREAM_INFORMATION_ENABLED
// send video stream information message to GCS
void send_video_stream_information(mavlink_channel_t chan);
#endif // AP_MAVLINK_MSG_VIDEO_STREAM_INFORMATION_ENABLED

HAL_Semaphore _rsem; // semaphore for multi-thread access
AP_Camera_Backend *primary; // primary camera backed
Expand Down
6 changes: 6 additions & 0 deletions libraries/AP_Camera/AP_Camera_Backend.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,9 @@ AP_Camera_Backend::AP_Camera_Backend(AP_Camera &frontend, AP_Camera_Params &para
void AP_Camera_Backend::init() {
#if AP_CAMERA_JSON_INFO_ENABLED
init_camera_information_from_json();
#if AP_MAVLINK_MSG_VIDEO_STREAM_INFORMATION_ENABLED
init_video_stream_information_from_json();
#endif // AP_MAVLINK_MSG_VIDEO_STREAM_INFORMATION_ENABLED
#endif // AP_CAMERA_JSON_INFO_ENABLED
}

Expand Down Expand Up @@ -338,6 +340,7 @@ void AP_Camera_Backend::send_camera_capture_status(mavlink_channel_t chan) const
image_index); // total number of images captured
}

#if AP_MAVLINK_MSG_VIDEO_STREAM_INFORMATION_ENABLED
// send video stream information message to GCS
void AP_Camera_Backend::send_video_stream_information(mavlink_channel_t chan) const {
#if AP_CAMERA_JSON_INFO_ENABLED
Expand All @@ -346,6 +349,7 @@ void AP_Camera_Backend::send_video_stream_information(mavlink_channel_t chan) co
}
#endif // AP_CAMERA_JSON_INFO_ENABLED
}
#endif

// setup a callback for a feedback pin. When on PX4 with the right FMU
// mode we can use the microsecond timer.
Expand Down Expand Up @@ -519,6 +523,7 @@ bool AP_Camera_Backend::_copy_json_field_string(const AP_JSON::value* obj, const
return true;
}

#if AP_MAVLINK_MSG_VIDEO_STREAM_INFORMATION_ENABLED
void AP_Camera_Backend::init_video_stream_information_from_json()
{
video_stream_info.is_valid = false;
Expand Down Expand Up @@ -568,6 +573,7 @@ void AP_Camera_Backend::init_video_stream_information_from_json()
debug(" video_stream_info.msg.uri='%s'", video_stream_info.msg.uri);
}
}
#endif // AP_MAVLINK_MSG_VIDEO_STREAM_INFORMATION_ENABLED

void AP_Camera_Backend::init_camera_information_from_json()
{
Expand Down
4 changes: 4 additions & 0 deletions libraries/AP_Camera/AP_Camera_Backend.h
Original file line number Diff line number Diff line change
Expand Up @@ -127,8 +127,10 @@ class AP_Camera_Backend
// send camera capture status message to GCS
virtual void send_camera_capture_status(mavlink_channel_t chan) const;

#if AP_MAVLINK_MSG_VIDEO_STREAM_INFORMATION_ENABLED
// send video stream information message to GCS
virtual void send_video_stream_information(mavlink_channel_t chan) const;
#endif

#if AP_CAMERA_SCRIPTING_ENABLED
// accessor to allow scripting backend to retrieve state
Expand Down Expand Up @@ -210,10 +212,12 @@ class AP_Camera_Backend
bool last_is_armed; // stores last arm/disarm state. true if it was armed lastly

#if AP_CAMERA_JSON_INFO_ENABLED
#if AP_MAVLINK_MSG_VIDEO_STREAM_INFORMATION_ENABLED
struct {
bool is_valid;
mavlink_video_stream_information_t msg;
} video_stream_info;
#endif // AP_MAVLINK_MSG_VIDEO_STREAM_INFORMATION_ENABLED
struct {
bool is_valid;
mavlink_camera_information_t msg;
Expand Down
2 changes: 2 additions & 0 deletions libraries/AP_Camera/AP_Camera_Mount.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ void AP_Camera_Mount::send_camera_capture_status(mavlink_channel_t chan) const
}
}

#if AP_MAVLINK_MSG_VIDEO_STREAM_INFORMATION_ENABLED
// send video stream information message to GCS
void AP_Camera_Mount::send_video_stream_information(mavlink_channel_t chan) const
{
Expand All @@ -139,5 +140,6 @@ void AP_Camera_Mount::send_video_stream_information(mavlink_channel_t chan) cons
(void)sent_by_mount;
#endif // AP_CAMERA_JSON_INFO_ENABLED
}
#endif // AP_MAVLINK_MSG_VIDEO_STREAM_INFORMATION_ENABLED

#endif // AP_CAMERA_MOUNT_ENABLED
2 changes: 2 additions & 0 deletions libraries/AP_Camera/AP_Camera_Mount.h
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,10 @@ class AP_Camera_Mount : public AP_Camera_Backend
// send camera capture status message to GCS
void send_camera_capture_status(mavlink_channel_t chan) const override;

#if AP_MAVLINK_MSG_VIDEO_STREAM_INFORMATION_ENABLED
// send video stream information message to GCS
void send_video_stream_information(mavlink_channel_t chan) const override;
#endif
};

#endif // AP_CAMERA_MOUNT_ENABLED

0 comments on commit 8403ca8

Please sign in to comment.