Code: Select all
0xC0000005: Access violation writing location 0x000001DE399D1000.
Here is the relevent code. I've also posted my cpp, header and main file in a zip if that is helpful.
Code: Select all
GstFlowReturn MainWindow::new_sample(GstElement* sink, CustomData* data)
{
GstSample* sample;
GstBuffer* buffer;
GstMapInfo info;
// printf("=====> In Appsink::new_sample(): \n");
if (!data->thisWidget->IsBufferReady)
{
printf("=====> In Appsink::new_sample(): "
"Buffer is not ready to accept new sample.\n");
data->thisWidget->RequestToDisplay(false); // Ignore this sample
return GST_FLOW_OK;
}
sample = gst_app_sink_pull_sample((GstAppSink*)sink);
if (sample)
{
//g_print("Sample is valid...\n");
buffer = gst_sample_get_buffer(sample);
if (buffer)
{
//g_print("Buffer is valid... counter = %d\n", data->new_sample_counter);
gst_buffer_map(buffer, &info, GST_MAP_READ);
if (data->new_sample_counter == 1)
{
data->m_size = info.size;
g_print("Size of MapInfo.data pointer: %llu bytes\n\n",
(unsigned long long)(sizeof(info.data))); // Should be 8 bytes
}
if (data->new_sample_counter < 5)
{
g_print("#%d: ", data->new_sample_counter);
/*g_print("Data size is %lu, MapInfo data pointer is %p\n", info.size, info.data);
printf(" data->ptrPtrBufferData = %p\n", data->ptrPtrBufferData );
printf(" *(data->ptrPtrBufferData) = %p\n", *(data->ptrPtrBufferData));
printf(" **(data->ptrPtrBufferData) = %p\n", **(data->ptrPtrBufferData));*/
data->new_sample_counter++;
}
if ((data->bmpBufferData) && (data->new_sample_counter > 1))
{
//printf("+++++> Calling memcpy() <+++++\n");
memcpy(data->bmpBufferData, info.data, (size_t)info.size);
//printf("+++++> Calling data->parent->RequestToDisplay() <+++++\n");
data->thisWidget->RequestToDisplay(true);
}
gst_buffer_unmap(buffer, &info);
Thanks!
Oh and this code is from a super helpful tutorial I found here: https://www.youtube.com/watch?v=1RotM1okx74