int get_metadata_internal(AVFormatContext *ic, AVDictionary **metadata) {
    if (!ic) {
        return FAILURE;
    }
    
    set_shoutcast_metadata(ic);
    av_dict_copy(metadata, ic->metadata, 0);
    
    return SUCCESS;
}
int set_data_source_l(State **ps, const char* path) {
    printf("set_data_source\n");
    int audio_index = -1;
    int video_index = -1;
    int i;
    
    State *state = *ps;
    
    printf("Path: %s\n", path);
    
    AVDictionary *options = NULL;
    av_dict_set(&options, "icy", "1", 0);
    av_dict_set(&options, "user-agent", "FFmpegMediaMetadataRetriever", 0);
    
    if (state->headers) {
        av_dict_set(&options, "headers", state->headers, 0);
    }
    
    if (state->offset > 0) {
        state->pFormatCtx = avformat_alloc_context();
        state->pFormatCtx->skip_initial_bytes = state->offset;
    }
    
    if (avformat_open_input(&state->pFormatCtx, path, NULL, &options) != 0) {
        printf("Metadata could not be retrieved\n");
        *ps = NULL;
        return FAILURE;
    }
    
    if (avformat_find_stream_info(state->pFormatCtx, NULL) < 0) {
        printf("Metadata could not be retrieved\n");
        avformat_close_input(&state->pFormatCtx);
        *ps = NULL;
        return FAILURE;
    }
    
    set_duration(state->pFormatCtx);
    
    set_shoutcast_metadata(state->pFormatCtx);
    
    //av_dump_format(state->pFormatCtx, 0, path, 0);
    
    // Find the first audio and video stream
    for (i = 0; i < state->pFormatCtx->nb_streams; i++) {
        if (state->pFormatCtx->streams[i]->codec->codec_type == AVMEDIA_TYPE_VIDEO && video_index < 0) {
            video_index = i;
        }
        
        if (state->pFormatCtx->streams[i]->codec->codec_type == AVMEDIA_TYPE_AUDIO && audio_index < 0) {
            audio_index = i;
        }
        
        set_codec(state->pFormatCtx, i);
    }
    
    if (audio_index >= 0) {
        stream_component_open(state, audio_index);
    }
    
    if (video_index >= 0) {
        stream_component_open(state, video_index);
    }
    
    /*if(state->video_stream < 0 || state->audio_stream < 0) {
	    avformat_close_input(&state->pFormatCtx);
     *ps = NULL;
     return FAILURE;
     }*/
    
    set_rotation(state->pFormatCtx, state->audio_st, state->video_st);
    set_framerate(state->pFormatCtx, state->audio_st, state->video_st);
    set_filesize(state->pFormatCtx);
    set_chapter_count(state->pFormatCtx);
    
    /*printf("Found metadata\n");
     AVDictionaryEntry *tag = NULL;
     while ((tag = av_dict_get(state->pFormatCtx->metadata, "", tag, AV_DICT_IGNORE_SUFFIX))) {
    	printf("Key %s: \n", tag->key);
    	printf("Value %s: \n", tag->value);
     }*/
    
    *ps = state;
    return SUCCESS;
}