Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- static GPtrArray*
- select_tracks_for_object(GESTimeline* timeline, GESClip* clip, GESTrackElement* tr_object, gpointer user_data)
- {
- GPtrArray* result = NULL;
- std::lock_guard<std::mutex> lck(timelines_mtx);
- auto it = timelines.find(timeline);
- if (it != timelines.end())
- {
- auto timeline_data = it->second;
- auto skip = false;
- // if the clip was found, use stream selection logic to possibly skip this GESTrackElement
- auto it2 = timeline_data->clips.find(clip);
- if (it2 != timeline_data->clips.end())
- {
- auto clip_data = it2->second;
- const gchar* name = ges_uri_clip_get_uri(GES_URI_CLIP(clip));
- gchar target_stream_id[256] = { 0 };
- if (GES_IS_URI_CLIP_ASSET(GES_TIMELINE_ELEMENT(clip)->asset))
- {
- auto clip_asset = GES_URI_CLIP_ASSET(GES_TIMELINE_ELEMENT(clip)->asset);
- auto info = ges_uri_clip_asset_get_info(clip_asset);
- auto streams = gst_discoverer_info_get_audio_streams(info);
- int stream_idx = 0;
- for (GList* tmp = streams; tmp; tmp = tmp->next)
- {
- if (GST_IS_DISCOVERER_AUDIO_INFO(tmp->data))
- {
- const gchar* stream_id = gst_discoverer_stream_info_get_stream_id(GST_DISCOVERER_STREAM_INFO(tmp->data));
- if (stream_idx == clip_data->target_stream)
- {
- strcpy(target_stream_id, stream_id);
- g_print("Correct stream id: %s\n", stream_id);
- break;
- }
- stream_idx++;
- }
- }
- }
- GESAsset* asset = ges_extractable_get_asset(GES_EXTRACTABLE(tr_object));
- if (GES_IS_URI_SOURCE_ASSET(asset))
- {
- GstDiscovererStreamInfo* stream_info = ges_uri_source_asset_get_stream_info(GES_URI_SOURCE_ASSET(asset));
- const gchar* stream_id = gst_discoverer_stream_info_get_stream_id(stream_info);
- g_print("StreamID: %s, Clip: %s, Stream Caps: %s, target_stream = %d\n", stream_id, name, gst_caps_to_string(gst_discoverer_stream_info_get_caps(stream_info)), clip_data->target_stream);
- if (strcmp(target_stream_id, stream_id) != 0)
- {
- skip = true;
- g_print("skipping...\n");
- }
- }
- }
- else
- {
- g_print("[CLIP WAS NOT FOUND]\n");
- }
- if (!skip)
- {
- result = g_ptr_array_new();
- for (GList* tmp = timeline->tracks; tmp; tmp = tmp->next)
- {
- GESTrack* track = GES_TRACK(tmp->data);
- if ((track->type & ges_track_element_get_track_type(tr_object)))
- {
- GESAsset* asset = ges_extractable_get_asset(GES_EXTRACTABLE(tr_object));
- if (GES_IS_URI_SOURCE_ASSET(asset))
- {
- GstDiscovererStreamInfo* stream_info = ges_uri_source_asset_get_stream_info(GES_URI_SOURCE_ASSET(asset));
- const gchar* stream_id = gst_discoverer_stream_info_get_stream_id(stream_info);
- g_print("[SELECTED STREAM ID]: %s\n", stream_id);
- }
- else
- {
- const gchar* name = G_OBJECT_TYPE_NAME(tr_object);
- g_print("[WHAT IS THIS?!?]: %s\n", name);
- }
- gst_object_ref(track);
- g_ptr_array_add(result, track);
- break;
- }
- }
- }
- }
- return result;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement