gboolean SongLoader::DataReady(GstPad*, GstBuffer* buf, void* self) { SongLoader* instance = static_cast<SongLoader*>(self); if (instance->state_ == Finished) return true; // Append the data to the buffer instance->buffer_.append(reinterpret_cast<const char*>(GST_BUFFER_DATA(buf)), GST_BUFFER_SIZE(buf)); qLog(Debug) << "Received total" << instance->buffer_.size() << "bytes"; if (instance->state_ == WaitingForMagic && (instance->buffer_.size() >= PlaylistParser::kMagicSize || !instance->IsPipelinePlaying())) { // Got enough that we can test the magic instance->MagicReady(); } return true; }
GstPadProbeReturn SongLoader::DataReady(GstPad*, GstPadProbeInfo* info, gpointer self) { SongLoader* instance = reinterpret_cast<SongLoader*>(self); if (instance->state_ == Finished) return GST_PAD_PROBE_OK; GstBuffer* buffer = gst_pad_probe_info_get_buffer(info); GstMapInfo map; gst_buffer_map(buffer, &map, GST_MAP_READ); // Append the data to the buffer instance->buffer_.append(reinterpret_cast<const char*>(map.data), map.size); qLog(Debug) << "Received total" << instance->buffer_.size() << "bytes"; gst_buffer_unmap(buffer, &map); if (instance->state_ == WaitingForMagic && (instance->buffer_.size() >= PlaylistParser::kMagicSize || !instance->IsPipelinePlaying())) { // Got enough that we can test the magic instance->MagicReady(); } return GST_PAD_PROBE_OK; }