Skip to content
Snippets Groups Projects
Commit 13cdf2a4 authored by Ron Tapia's avatar Ron Tapia Committed by Rachael Huxford
Browse files

Rework of check in devshmsrc for specific filename suffixes

parent e66ecb72
No related branches found
No related tags found
1 merge request!510Injection Streamer
......@@ -449,12 +449,15 @@ static GstFlowReturn devshm_get_filenames (GstBaseSrc *basesrc)
size_t parsedEventsLen = 0;
GString *filenameGstringp;
int count = 0;
int numFilenamesAdded = 0;
int pollret;
struct pollfd pfd;
timeval startTv, endTv;
double elapsedSeconds;
struct inotify_event *eventp;
GstClockTime startPoll;
char* suffixStart;
size_t eventNameLen;
// Poll the notify file descriptor.
// The timeout is set in datasource.py.
......@@ -514,24 +517,6 @@ static GstFlowReturn devshm_get_filenames (GstBaseSrc *basesrc)
// fetch the buffer/event from the element property
eventp = (struct inotify_event *) element->inotifyEventp;
// check that filename has desired suffix
// if not set, skip and take all filenames
if (element->watch_suffix){
// copy the suffix of filename into new char array for comparison
gchar fileSuffix[strlen(element->watch_suffix)];
memcpy(fileSuffix, eventp->name + (eventp->len - strlen(element->watch_suffix)), sizeof(strlen(element->watch_suffix)));
if (fileSuffix != element->watch_suffix){
GST_DEBUG_OBJECT(element, "Filename does not match requested suffix. Filename: \"%s\", FileSuffix:\"%s\", Desired Suffix: \"%s\"", element->name, fileSuffix, element->watch_suffix);
// if they are not the same, skip adding filename to queue
// go to done instead
g_free(fileSuffix);
GST_DEBUG_OBJECT(element, "Made it after freeing fileSuffix");
goto done;
}
// if they are the same, free the char array and continue
g_free(fileSuffix);
}
// if space of events read is less that the size of available available events, read more.
GstClockTime fileTimestamp;
while (parsedEventsLen < (size_t) readResult) {
......@@ -548,6 +533,19 @@ static GstFlowReturn devshm_get_filenames (GstBaseSrc *basesrc)
goto done;
}
// If watch_suffix is set, test the suffix and ignore
// the event if the suffix does not match.
if (element->watch_suffix){
eventNameLen = strlen(eventp->name);
if (eventNameLen < element->watch_suffix_len) goto next_event;
suffixStart = eventp->name + eventNameLen - element->watch_suffix_len;
if (g_ascii_strncasecmp(element->watch_suffix, suffixStart, element->watch_suffix_len)) {
GST_DEBUG_OBJECT(element, "Filename does not match watch_suffix. Filename: \"%s\", Suffix:\"%s\", Desired Suffix: \"%s\"", element->name,
suffixStart, element->watch_suffix);
goto next_event;
}
}
// after checks, turn the event name into a filename string.
filenameGstringp = g_string_new(eventp->name);
......@@ -563,6 +561,7 @@ static GstFlowReturn devshm_get_filenames (GstBaseSrc *basesrc)
// Under normal operation. The assumption that inotify events are ordered in time is good.
if (fileTimestamp > element->lastFileTimestamp){
g_queue_push_tail(element->filenameQueue, (gpointer) filenameGstringp); // Add the string to the filenameQueue
numFilenamesAdded++;
element->lastFileTimestamp = fileTimestamp; // Keep track of the timestamp of the last file added to the queue.
} else{
g_string_free(filenameGstringp, TRUE);
......@@ -570,12 +569,13 @@ static GstFlowReturn devshm_get_filenames (GstBaseSrc *basesrc)
}
// Add this event/buffer to the total parsed length.
next_event:
parsedEventsLen += sizeof(struct inotify_event) + eventp->len;
eventp = (struct inotify_event *) (element->inotifyEventp + parsedEventsLen);
count++;
}
GST_DEBUG_OBJECT(element, "Found %d new files in \"%s\"", count, element->name);
GST_DEBUG_OBJECT(element, "Found %d new files (%d events) in \"%s\"", numFilenamesAdded, count, element->name);
done:
return result;
......@@ -719,6 +719,9 @@ static void set_property(GObject *object, guint id, const GValue *value, GParamS
case ARG_WATCH_SUFFIX:
g_free(element->watch_suffix);
element->watch_suffix = g_value_dup_string(value);
if (element->watch_suffix != NULL) {
element->watch_suffix_len = strlen(element->watch_suffix);
}
break;
default:
......@@ -748,10 +751,6 @@ static void get_property(GObject *object, guint id, GValue *value, GParamSpec *p
g_value_set_double(value, element->wait_time);
break;
case ARG_WATCH_SUFFIX:
g_value_set_string(value, element->watch_suffix);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID(object, id, pspec);
break;
......
......@@ -53,6 +53,7 @@ typedef struct {
char *name; // should be the full path to a directory under /dev/shm
double wait_time; // time passed in as seconds to wait for new data before timing out.
gchar *watch_suffix; // suffix of filetype to poll for under *name
size_t watch_suffix_len;
// latency
GstClockTimeDiff max_latency;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment