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

Add little/big endian check #25

Open
wants to merge 1 commit into
base: ros2
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions gst_bridge/src/rosimagesrc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,7 @@ void rosimagesrc_set_property (GObject * object, guint property_id,
}
}


void rosimagesrc_get_property (GObject * object, guint property_id,
GValue * value, GParamSpec * pspec)
{
Expand Down Expand Up @@ -243,7 +244,15 @@ void rosimagesrc_get_property (GObject * object, guint property_id,
break;
}
}

static int isLittleEndian() {
// we can just use system's default
int d = 0x5;
char *ptr = (char *)&d;
if (*ptr == 0) {
return 0; // not little endian
}
return 1; // little endian
}
static void rosimagesrc_set_msg_props_from_caps_string(Rosimagesrc * src, gchar * caps_string)
{
int width;
Expand All @@ -268,7 +277,7 @@ static void rosimagesrc_set_msg_props_from_caps_string(Rosimagesrc * src, gchar
GstVideoFormat format = gst_video_format_from_string (format_str);

step = gst_video_format_get_info(format)->pixel_stride[0];
endianness = G_LITTLE_ENDIAN; // XXX pull this from somewhere
endianness = isLittleEndian() ? G_LITTLE_ENDIAN: G_BIG_ENDIAN;

// XXX this check is redundant right now, we should allow overrides by making ros-encoding READWRITE
if(0 == g_strcmp0(src->encoding, ""))
Expand Down