Esempio n. 1
0
	void retag_set_info(t_uint32 p_subsong, const file_info &p_info, abort_callback &p_abort)
	{
		ASAPInfo *info = const_cast<ASAPInfo *>(ASAP_GetInfo(asap));
		ASAPInfo_SetAuthor(info, empty_if_null(p_info.meta_get("composer", 0)));
		ASAPInfo_SetTitle(info, empty_if_null(p_info.meta_get("title", 0)));
		ASAPInfo_SetDate(info, empty_if_null(p_info.meta_get("date", 0)));
	}
Esempio n. 2
0
void stream_encoders::update_metadata(const file_info&p_info){
	metadata.remove_all();

	pfc::string artist,title;
    for (unsigned i=0;i<p_info.meta_get_count();i++) {
		pfc::string name = p_info.meta_enum_name(i);
		for (unsigned j=0;j<p_info.meta_enum_value_count(i);j++){
			pfc::string value = p_info.meta_enum_value(i,j);
			pfc::string buffer=name+"="+value;
			metadata.add_item(buffer);

			if(pfc::string::g_equalsCaseInsensitive(name,"artist"))
				artist=value;
			if(pfc::string::g_equalsCaseInsensitive(name,"title"))
				title=value;
		}
    }

	pfc::string meta=artist+" - "+title;
	for(unsigned i=0;i<enc_list.get_count();++i){
		strcpy(enc_list[i]->config->gSongTitle,(char*)meta.ptr());
		enc_list[i]->config->ice2songChange=true;
		updateSongTitle(enc_list[i]->config,0);
	}
}
static t_size merge_tags_calc_rating_by_index(const file_info & p_info,t_size p_index) {
	t_size n,m = p_info.meta_enum_value_count(p_index);
	t_size ret = 0;
	for(n=0;n<m;n++)
		ret += strlen(p_info.meta_enum_value(p_index,n)) + 10;//yes, strlen on utf8 data, plus a slight bump to prefer multivalue over singlevalue w/ separator
	return ret;
}
void file_info::copy(const file_info & p_source)
{
    if (&p_source != this) {
        copy_meta(p_source);
        copy_info(p_source);
        set_length(p_source.get_length());
        set_replaygain(p_source.get_replaygain());
    }
}
Esempio n. 5
0
static void info_meta_add(file_info & info, const char * tag, pfc::ptr_list_t< const char > const& values)
{
	t_size count = info.meta_get_count_by_name( tag );
	if ( count )
	{
		// append as another line
		pfc::string8 final = info.meta_get(tag, count - 1);
		final += "\r\n";
		final += values[0];
void file_info::copy_meta_single_rename_ex(const file_info & p_source,t_size p_index,const char * p_new_name,t_size p_new_name_length)
{
    t_size n, m = p_source.meta_enum_value_count(p_index);
    t_size new_index = pfc_infinite;
    for(n=0; n<m; n++)
    {
        const char * value = p_source.meta_enum_value(p_index,n);
        if (n == 0) new_index = meta_set_ex(p_new_name,p_new_name_length,value,pfc_infinite);
        else meta_add_value(new_index,value);
    }
}
Esempio n. 7
0
void selection_properties_t::g_print_field(const char * field, const file_info & p_info, pfc::string_base & p_out)
{
	t_size meta_index = p_info.meta_find(field);
	if (meta_index != pfc_infinite)
	{
		t_size i, count = p_info.meta_enum_value_count(meta_index);
		for (i = 0; i < count; i++)
			p_out << p_info.meta_enum_value(meta_index, i) << (i + 1 < count ? "; " : "");

	}
}
void file_info::copy_meta_single_nocheck(const file_info & p_source,t_size p_index)
{
    const char * name = p_source.meta_enum_name(p_index);
    t_size n, m = p_source.meta_enum_value_count(p_index);
    t_size new_index = pfc_infinite;
    for(n=0; n<m; n++)
    {
        const char * value = p_source.meta_enum_value(p_index,n);
        if (n == 0) new_index = meta_set_nocheck(name,value);
        else meta_add_value(new_index,value);
    }
}
Esempio n. 9
0
	void get_info(t_uint32 p_subsong, file_info &p_info, abort_callback &p_abort)
	{
		int duration = get_song_duration(p_subsong, false);
		if (duration >= 0)
			p_info.set_length(duration / 1000.0);
		const ASAPInfo *info = ASAP_GetInfo(asap);
		p_info.info_set_int("channels", ASAPInfo_GetChannels(info));
		p_info.info_set_int("subsongs", ASAPInfo_GetSongs(info));
		meta_set(p_info, "composer", ASAPInfo_GetAuthor(info));
		meta_set(p_info, "title", ASAPInfo_GetTitle(info));
		meta_set(p_info, "date", ASAPInfo_GetDate(info));
	}
Esempio n. 10
0
	void get_info( file_info & p_info, abort_callback & p_abort )
	{
		ModPlugFile* m_info = ModPlug_Load(file_buffer.get_ptr(), file_buffer.get_size());
		p_info.info_set( "encoding", "synthesized" );
		int type_module = ModPlug_GetModuleType(m_info);
		p_info.info_set( "codec", "Module file" );
		p_info.info_set_int( "channels", 2 );
		p_info.meta_set( "title", pfc::stringcvt::string_utf8_from_ansi(  ModPlug_GetName(m_info)  ));
		int len = ModPlug_GetLength(m_info);
		len /= 1000;
		p_info.set_length( len );
		if(m_info)ModPlug_Unload(m_info);
	}
Esempio n. 11
0
	void get_info(file_info & p_info,abort_callback & p_abort) {
		p_info.set_length( mod->get_duration_seconds() );
		p_info.info_set_int( "samplerate", settings.samplerate );
		p_info.info_set_int( "channels", settings.channels );
		p_info.info_set_int( "bitspersample", 32 );
		std::vector<std::string> keys = mod->get_metadata_keys();
		for ( std::vector<std::string>::iterator key = keys.begin(); key != keys.end(); ++key ) {
			if ( *key == "message_raw" ) {
				continue;
			}
			p_info.meta_set( (*key).c_str(), mod->get_metadata( *key ).c_str() );
		}
	}
bool file_info::g_is_meta_equal(const file_info & p_item1,const file_info & p_item2) {
    const t_size count = p_item1.meta_get_count();
    if (count != p_item2.meta_get_count()) {
        //uDebugLog() << "meta count mismatch";
        return false;
    }
    pfc::map_t<const char*,t_size,field_name_comparator> item2_meta_map;
    for(t_size n=0; n<count; n++) {
        item2_meta_map.set(p_item2.meta_enum_name(n),n);
    }
    for(t_size n1=0; n1<count; n1++) {
        t_size n2;
        if (!item2_meta_map.query(p_item1.meta_enum_name(n1),n2)) {
            //uDebugLog() << "item2 doesn't have " << p_item1.meta_enum_name(n1);
            return false;
        }
        t_size value_count = p_item1.meta_enum_value_count(n1);
        if (value_count != p_item2.meta_enum_value_count(n2)) {
            //uDebugLog() << "meta value count mismatch: " << p_item1.meta_enum_name(n1) << " : " << value_count << " vs " << p_item2.meta_enum_value_count(n2);
            return false;
        }
        for(t_size v = 0; v < value_count; v++) {
            if (strcmp(p_item1.meta_enum_value(n1,v),p_item2.meta_enum_value(n2,v)) != 0) {
                //uDebugLog() << "meta mismatch: " << p_item1.meta_enum_name(n1) << " : " << p_item1.meta_enum_value(n1,v) << " vs " << p_item2.meta_enum_value(n2,v);
                return false;
            }
        }
    }
    return true;
}
Esempio n. 13
0
void IMA4Decoder::get_info(file_info &info)
{
    info.info_set("codec",    "IMA 4:1");
    info.info_set("encoding", "lossy");
    info.info_set_int("samplerate", m_format.asbd.mSampleRate);
    uint32_t channel_mask = m_format.channel_mask;
    std::string channels;
    if (channel_mask) {
        channels = Helpers::describe_channels(channel_mask);
        info.info_set("channels", channels.c_str());
    } else {
        info.info_set_int("channels", m_format.asbd.mChannelsPerFrame);
    }
}
void file_info::_add_tag(const file_info & otherTag) {
	this->set_replaygain( replaygain_info::g_merge( this->get_replaygain(), otherTag.get_replaygain() ) );

	const char * tt1 = this->info_get(_tagtype);
	const char * tt2 = otherTag.info_get(_tagtype);
	if (tt2) {
		if (tt1) {
			this->info_set(_tagtype, PFC_string_formatter() << tt1 << "|" << tt2);
		} else {
			this->info_set(_tagtype, tt2);
		}
	}

}
static t_size merge_tags_calc_rating(const file_info & p_info,const char * p_field) {
	t_size field_index = p_info.meta_find(p_field);
	if (field_index != ~0) {
		return merge_tags_calc_rating_by_index(p_info,field_index);
	} else {
		return 0;
	}
}
Esempio n. 16
0
 void get_info(file_info &info, abort_callback &abort)
 {
     m_demuxer->get_metadata(info);
     auto asbd = m_demuxer->format().asbd;
     info.set_length(m_demuxer->duration() / asbd.mSampleRate);
     info.info_set_bitrate(m_demuxer->bitrate());
     info.info_set_int("samplerate", asbd.mSampleRate);
     uint32_t channel_mask = m_demuxer->format().channel_mask;
     std::string channels;
     if (channel_mask) {
         channels = Helpers::describe_channels(channel_mask);
         info.info_set("channels", channels.c_str());
     } else {
         info.info_set_int("channels", asbd.mChannelsPerFrame);
     }
     m_decoder->get_info(info);
 }
void file_info::copy_info(const file_info & p_source)
{
    if (&p_source != this) {
        info_remove_all();
        t_size n, m = p_source.info_get_count();
        for(n=0; n<m; n++)
            copy_info_single_nocheck(p_source,n);
    }
}
Esempio n. 18
0
	virtual bool instantiate( const file_info & info, decode_postprocessor_instance::ptr & out )
	{
		if (info.info_get_int("samplerate") != 44100) return false;

		const char* enabled = info.meta_get("pre_emphasis", 0);
		if (enabled == NULL) enabled = info.meta_get("pre-emphasis", 0);
		if (enabled == NULL)
		{
			return false;
		}

		if (pfc::stricmp_ascii(enabled, "1") == 0 || pfc::stricmp_ascii(enabled, "on") == 0 || pfc::stricmp_ascii(enabled, "yes") == 0)
		{
			console::print("Pre-emphasis detected and enabled in track. Running filter");
			out = new service_impl_t<deemph_postprocessor_instance>;
			return true;
		}
	}
bool file_info_filter_scale_bpm::apply_filter(metadb_handle_ptr p_track, t_filestats p_stats, file_info & p_info)
{
	const char * str = p_info.meta_get(m_bpm_tag, 0);

	float bpm = 0.0f;
	if ((str != NULL) && (sscanf_s(str, "%f", &bpm) == 1))
	{
		bpm = static_cast<float>(bpm * m_scale);

		p_info.meta_set(m_bpm_tag, format_bpm(bpm));

		return true;
	}
	else
	{
		return false;
	}
}
Esempio n. 20
0
bool TagWriter::apply_filter(metadb_handle_ptr p_location, t_filestats p_stats, file_info & p_info) {
	try {
		auto tags = files[p_location];
		for (auto tag = tags.first(); tag.is_valid(); tag++) {
			// TODO: return false if all info is identical
			p_info.meta_remove_field(tag->m_key);
			// TODO: text multivalues
			tag->m_value.for_each([&](pfc::string8 &value) {
				if (!value.is_empty()) {
					p_info.meta_add(tag->m_key, value);
				}
			});
		}
		return true;
	} catch (pfc::exception_map_entry_not_found) {
		return false;
	}
}
Esempio n. 21
0
	bool decode_get_dynamic_info( file_info & p_out, double & p_timestamp_delta )
	{
		if ( first_block )
		{
			first_block = false;
			p_out.info_set_int( "samplerate", 44100 );
			return true;
		}
		return false;
	}
Esempio n. 22
0
static void copy_info(char *dest, const file_info &p_info, const char *p_name)
{
	const char *src;
	int i = 0;
	src = p_info.meta_get(p_name, 0);
	if (src != NULL)
		for (; i < 127 && src[i] != '\0'; i++)
			dest[i] = src[i];
	dest[i] = '\0';
}
Esempio n. 23
0
static void strip_redundant_track_meta(unsigned p_tracknumber,const file_info & p_cueinfo,file_info_record::t_meta_map & p_meta,const char * p_metaname) {
	t_size metaindex = p_cueinfo.meta_find(p_metaname);
	if (metaindex == pfc_infinite) return;
	pfc::string_formatter namelocal;
	build_cue_meta_name(p_metaname,p_tracknumber,namelocal);
	{
		const file_info_record::t_meta_value * val = p_meta.query_ptr(namelocal);
		if (val == NULL) return;
		file_info_record::t_meta_value::const_iterator iter = val->first();
		for(t_size valwalk = 0, valcount = p_cueinfo.meta_enum_value_count(metaindex); valwalk < valcount; ++valwalk) {
			if (iter.is_empty()) return;
			if (strcmp(*iter,p_cueinfo.meta_enum_value(metaindex,valwalk)) != 0) return;
			++iter;
		}
		if (!iter.is_empty()) return;
	}
	//success
	p_meta.remove(namelocal);
}
Esempio n. 24
0
void embeddedcue_metadata_manager::get_tag(file_info & p_info) const {
	if (!have_cuesheet()) {
		m_content.query_ptr((unsigned)0)->m_info.to_info(p_info);
		p_info.meta_remove_field("cuesheet");
	} else {
		cue_creator::t_entry_list entries;
		m_content.enumerate(__get_tag_cue_track_list_builder(entries));
		pfc::string_formatter cuesheet;
		cue_creator::create(cuesheet,entries);
		entries.remove_all();
		//parse it back to see what info got stored in the cuesheet and what needs to be stored outside cuesheet in the tags
		cue_parser::parse_full(cuesheet,entries);
		file_info_record output;

		
		

		{
			file_info_record::t_meta_map globals;
			//1. find global infos and forward them
			{
				field_name_list fields;
				m_content.enumerate(__get_tag__enum_fields_enumerator(fields));
				fields.enumerate(__get_tag__filter_globals(m_content,globals));
			}
			
			output.overwrite_meta(globals);

			//2. find local infos
			m_content.enumerate(__get_tag__local_field_filter(globals,output.m_meta));
		}
		

		//strip redundant titles and tracknumbers that the cuesheet already contains
		for(cue_creator::t_entry_list::const_iterator iter = entries.first(); iter.is_valid(); ++iter) {
			strip_redundant_track_meta(iter->m_track_number,iter->m_infos,output.m_meta,"tracknumber");
			strip_redundant_track_meta(iter->m_track_number,iter->m_infos,output.m_meta,"title");
		}


		//add tech infos etc

		{
			const track_record * rec = m_content.query_ptr((unsigned)0);
			if (rec != NULL) {
				output.set_length(rec->m_info.get_length());
				output.set_replaygain(rec->m_info.get_replaygain());
				output.overwrite_info(rec->m_info.m_info);
			}
		}
		output.meta_set("cuesheet",cuesheet);
		output.to_info(p_info);
	}
}
Esempio n. 25
0
	virtual void get_info(t_uint32 subsong, file_info & p_info,abort_callback & p_abort) {
		t_uint32 sample_rate = get_sample_rate();
		m_head.input->get_info(subsong, p_info, p_abort);
		pfc::string8 name;
		name << get_info_prefix();
		t_size prefixlen = name.get_length();
		name << "head_length";
		p_info.info_set(name, format_samples_ex(m_head.samples, sample_rate));
		name.truncate(prefixlen);
		name << "body_length";
		p_info.info_set(name, format_samples_ex(m_body.samples, sample_rate));
		p_info.set_length(audio_math::samples_to_time(m_head.samples + m_body.samples, sample_rate));
		if (m_autoprobe) {
			name.truncate(prefixlen);
			name << "autoprobe";
			pfc::string8 value;
			value << "type=" << g_get_short_name() << " head-suffix=" << m_head.suffix << " body-suffix=" << m_body.suffix;
			p_info.info_set(name, value);
		}
	}
Esempio n. 26
0
bool t_cuesheet_index_list::from_infos(file_info const & p_in,double p_base)
{
	double pregap;
	bool found = false;
	if (!parse_value(p_in.info_get("pregap"),pregap)) pregap = 0;
	else found = true;
	m_positions[0] = p_base - pregap;
	m_positions[1] = p_base;
	for(unsigned n=2;n<count;n++)
	{
		char namebuffer[16];
		sprintf_s(namebuffer,"index %02u",n);
		double temp;
		if (parse_value(p_in.info_get(namebuffer),temp)) {
			m_positions[n] = temp + p_base; found = true;
		} else {
			m_positions[n] = 0;
		}
	}
	return found;	
}
Esempio n. 27
0
void t_cuesheet_index_list::to_infos(file_info & p_out) const
{
	double base = m_positions[1];

	if (base > 0) {
		p_out.info_set("referenced_offset",cuesheet_format_index_time(base));
	}
	
	if (m_positions[0] < base)
		p_out.info_set("pregap",cuesheet_format_index_time(base - m_positions[0]));
	else
		p_out.info_remove("pregap");

	p_out.info_remove("index 00");	
	p_out.info_remove("index 01");
	
	for(unsigned n=2;n<count;n++)
	{
		char namebuffer[16];
		sprintf_s(namebuffer,"index %02u",n);
		double position = m_positions[n] - base;
		if (position > 0)
			p_out.info_set(namebuffer,cuesheet_format_index_time(position));
		else
			p_out.info_remove(namebuffer);
	}
}
Esempio n. 28
0
 void get_info(file_info & p_info, abort_callback & p_abort)
 {
     p_info.info_set_int("bitrate", (t_int64)m_decoder->avg_bitrate / 1000);
     p_info.info_set_int("samplerate", m_decoder->sample_rate);
     p_info.info_set_int("bitspersample", get_bps_for_format(config.format));
     p_info.info_set_int("channels", config.speakers);
     p_info.info_set("codec", m_decoder->format);
     p_info.set_length( (double) m_decoder->length);
 }
Esempio n. 29
0
std::size_t file_info_hasher::hash(const file_info&v) {
    std::size_t seed(0);

    combine(seed, v.documentation());
    combine(seed, v.includes());
    combine(seed, v.descriptor());
    combine(seed, v.header_guard());
    combine(seed, hash_boost_filesystem_path(v.file_path()));
    combine(seed, hash_boost_filesystem_path(v.relative_path()));
    combine(seed, hash_boost_shared_ptr_dogen_cpp_entity(v.entity()));

    return seed;
}
void tag_processor::read_id3v2_trailing(const service_ptr_t<file> & p_file,file_info & p_info,abort_callback & p_abort)
{
    file_info_impl id3v2, trailing;
    bool have_id3v2 = true, have_trailing = true;
    try {
        read_id3v2(p_file,id3v2,p_abort);
    } catch(exception_io_data) {
        have_id3v2 = false;
    }
    if (!have_id3v2 || !p_file->is_remote()) try {
            read_trailing(p_file,trailing,p_abort);
        } catch(exception_io_data) {
            have_trailing = false;
        }

    if (!have_id3v2 && !have_trailing) throw exception_tag_not_found();

    if (have_id3v2) {
        p_info._set_tag(id3v2);
        if (have_trailing) p_info._add_tag(trailing);
    } else {
        p_info._set_tag(trailing);
    }
}