[Dsmyth-checkins] SF.net SVN: dsmyth: [547] trunk/MythTVReader/PropertyHandler
Brought to you by:
tobbej
From: <to...@us...> - 2007-07-15 12:29:48
|
Revision: 547 http://svn.sourceforge.net/dsmyth/?rev=547&view=rev Author: tobbej Date: 2007-07-15 05:20:42 -0700 (Sun, 15 Jul 2007) Log Message: ----------- more properties Modified Paths: -------------- trunk/MythTVReader/PropertyHandler/MythTVProperties.cpp trunk/MythTVReader/PropertyHandler/MythTVProperties.h trunk/MythTVReader/PropertyHandler/PropertyHandler.vcproj trunk/MythTVReader/PropertyHandler/stdafx.h Modified: trunk/MythTVReader/PropertyHandler/MythTVProperties.cpp =================================================================== --- trunk/MythTVReader/PropertyHandler/MythTVProperties.cpp 2007-07-15 11:47:26 UTC (rev 546) +++ trunk/MythTVReader/PropertyHandler/MythTVProperties.cpp 2007-07-15 12:20:42 UTC (rev 547) @@ -25,7 +25,6 @@ #include "stdafx.h" #include "MythTVProperties.h" #include "utils.h" -#include <propvarutil.h> // CMythTVProperties @@ -116,8 +115,8 @@ HRESULT hr=PSCreateMemoryPropertyStore(IID_PPV_ARGS(&m_pStoreCache)); if(SUCCEEDED(hr)) { - StoreDataInCache(PKEY_Kind,KIND_RECORDEDTV); - StoreDataInCache(PKEY_KindText,L"MythTV recording"); + StoreDataInCacheStringVector(PKEY_Kind,CAtlStringW(KIND_RECORDEDTV)); + StoreDataInCache(PKEY_KindText,L"Recorded TV"); CNuvInfo::CFileInfo info; CNuvInfo FileInfo; @@ -127,11 +126,13 @@ StoreDataInCache(PKEY_Title,info.m_ProgramInfo.m_title); StoreDataInCache(PKEY_Media_SubTitle,info.m_ProgramInfo.m_subtitle); StoreDataInCache(PKEY_RecordedTV_ProgramDescription,info.m_ProgramInfo.m_description); + //must be an integer but chanstr can be a channel number that can't be + //converted to an integer //StoreDataInCache(PKEY_RecordedTV_ChannelNumber,info.m_ProgramInfo.m_chanstr); StoreDataInCache(PKEY_RecordedTV_StationCallSign,info.m_ProgramInfo.m_chansign); StoreDataInCache(PKEY_RecordedTV_StationName,info.m_ProgramInfo.m_channame); - CTimeSpan tmp=info.m_ProgramInfo.m_recendts-info.m_ProgramInfo.m_recstartts; + CTimeSpan tmp=info.m_ProgramInfo.m_endts-info.m_ProgramInfo.m_startts; ULONGLONG length=tmp.GetTotalSeconds()*10000000; StoreDataInCache(PKEY_Media_Duration,length); @@ -143,16 +144,134 @@ //SYSTEMTIME must be in UTC so we have to convert our timestamp from //localtime to UTC TIME_ZONE_INFORMATION tz; - if(GetTimeZoneInformation(&tz)!=TIME_ZONE_ID_INVALID) + DWORD dwRet=GetTimeZoneInformation(&tz); + if(dwRet!=TIME_ZONE_ID_INVALID) { TzSpecificLocalTimeToSystemTime(&tz,&st,&ut); + //something is wrong here one hour off sometimes if(SystemTimeToFileTime(&ut,&ft)) { StoreDataInCache(PKEY_RecordedTV_RecordingTime,ft); } } StoreDataInCacheStringVector(PKEY_Keywords,info.m_ProgramInfo.m_category); + StoreDataInCache(PKEY_RecordedTV_IsRepeatBroadcast,(BOOL)(info.m_ProgramInfo.m_repeat ? TRUE : FALSE)); + StoreDataInCache(PKEY_RecordedTV_IsHDContent,(BOOL)(info.m_ProgramInfo.m_programflags&FL_HDTV ? TRUE : FALSE)); + StoreDataInCache(PKEY_RecordedTV_IsClosedCaptioningAvailable,(BOOL)(info.m_ProgramInfo.m_programflags&FL_CC ? TRUE : FALSE)); + try + { + CDBUtils util; + mysqlpp::Connection con(false); + if(util.Connect(con)) + { + mysqlpp::Query query=con.query(); + query << "SELECT airdate FROM "; + query << (info.m_ProgramInfo.m_filesize>0 ? "recordedprogram" : "program"); + query << " WHERE chanid = %0q:chanid AND starttime = FROM_UNIXTIME(%1q:starttime) ;"; + query.parse(); + query.def["chanid"]=info.m_ProgramInfo.m_chanid; + query.def["starttime"]=info.m_ProgramInfo.m_startts.GetTime(); + mysqlpp::Result res=query.store(); + if(res && res.num_rows()>0) + { + mysqlpp::Row row=res.at(0); + ULONG year=row.at(0); + if(year>0) + { + StoreDataInCache(PKEY_Media_Year,year); + } + } + if(info.m_ProgramInfo.m_endts!=info.m_ProgramInfo.m_startts) + { + mysqlpp::Query query2=con.query(); + query2 << "SELECT role,people.name FROM "; + query2 << (info.m_ProgramInfo.m_filesize>0 ? + "recordedcredits AS credits" : "credits"); + query2 << " LEFT JOIN people ON credits.person = people.person" + " WHERE credits.chanid = %0q:chanid" + " AND credits.starttime = FROM_UNIXTIME(%1q:starttime)" + " ORDER BY role;"; + query2.parse(); + query2.def["chanid"]=info.m_ProgramInfo.m_chanid; + query2.def["starttime"]=info.m_ProgramInfo.m_startts.GetTime(); + mysqlpp::Result res=query2.store(); + + CAtlStringW actors; + CAtlStringW directors; + CAtlStringW hosts; + CAtlStringW gueststars; + CAtlStringW producers; + + mysqlpp::Row row; + for(mysqlpp::Row::size_type i=0;row=res.at(i);++i) + { + if(row["role"].compare("actor")==0) + { + actors+=CA2W(row["name"],CP_UTF8); + actors+=L";"; + } + else if(row["role"].compare("director")==0) + { + directors+=CA2W(row["name"],CP_UTF8); + directors+=L";"; + } + else if(row["role"].compare("host")==0) + { + hosts+=CA2W(row["name"],CP_UTF8); + hosts+=L";"; + } + else if(row["role"].compare("guest_star")==0) + { + gueststars+=CA2W(row["name"],CP_UTF8); + gueststars+=";"; + } + else if(row["role"].compare("producer")==0) + { + producers+=CA2W(row["name"],CP_UTF8); + producers+=L";"; + } + } + if(directors.GetLength()>0) + { + StoreDataInCacheStringVector(PKEY_Video_Director,directors); + } + if(producers.GetLength()>0) + { + StoreDataInCacheStringVector(PKEY_Media_Producer,producers); + } + if(actors.GetLength()>0 || + directors.GetLength()>0 || + hosts.GetLength()>0 || + gueststars.GetLength()>0 ) + { + CAtlStringW credits; + actors.Replace(';','/'); + credits=actors; + credits+=L";"; + directors.Replace(';','/'); + credits+=directors; + credits+=L";"; + hosts.Replace(';','/'); + credits+=hosts; + credits+=L";"; + gueststars.Replace(';','/'); + credits+=gueststars; + + StoreDataInCache(PKEY_RecordedTV_Credits,credits); + } + + } + } + } + catch(mysqlpp::Exception &e) + { + ATLTRACE(_T("%s(%d) : CMythTVProperties::Initialize db exception: %s\n"),__FILE__,__LINE__,e.what()); + } + //only using 4 stars as a maximum since thats what mythtv uses + //maybe we shoud use all 5? + StoreDataInCache(PKEY_Rating,(ULONG)(info.m_ProgramInfo.m_stars*100-25+1)); + CAtlStringW contents; contents=info.m_ProgramInfo.m_title; contents+=L" "; @@ -171,13 +290,6 @@ StoreDataInCache(PKEY_Video_FrameWidth,(ULONG)info.m_rtFileHeader.width); StoreDataInCache(PKEY_Video_FrameRate,(ULONG)info.m_rtFileHeader.fps*1000); - CAtlStringW VideoFourCC; - char tmp[5]; - tmp[4]=0; - memcpy_s(tmp,4,&info.m_ExtendedData.video_fourcc,4); - VideoFourCC=CA2W(tmp); - StoreDataInCache(PKEY_Video_FourCC,VideoFourCC); - if(info.m_bUsingExtendedData) { double rate=info.m_ExtendedData.audio_bits_per_sample*info.m_ExtendedData.audio_channels*info.m_ExtendedData.audio_sample_rate/(1000*info.m_ExtendedData.audio_compression_ratio); @@ -185,6 +297,17 @@ StoreDataInCache(PKEY_Audio_EncodingBitrate,(ULONG)bitrate*1000); StoreDataInCache(PKEY_Audio_ChannelCount,(ULONG)info.m_ExtendedData.audio_channels); StoreDataInCache(PKEY_Audio_SampleRate,(ULONG)info.m_ExtendedData.audio_sample_rate); + if(info.m_ExtendedData.audio_fourcc==MAKEFOURCC('L','A','M','E')) + { + StoreDataInCache(PKEY_Audio_Compression,L"MP3"); + } + else if(info.m_ExtendedData.audio_fourcc==MAKEFOURCC('L','A','M','E')) + { + StoreDataInCache(PKEY_Audio_Compression,L"PCM"); + } + + StoreDataInCache(PKEY_Video_EncodingBitrate,info.m_ExtendedData.lavc_bitrate); + StoreDataInCache(PKEY_Video_FourCC,(ULONG)info.m_ExtendedData.video_fourcc); } } } @@ -238,7 +361,17 @@ } PropVariantClear(&pv); } - +void CMythTVProperties::StoreDataInCache(PROPERTYKEY key,BOOL data) +{ + PROPVARIANT pv; + PropVariantInit(&pv); + HRESULT hr=InitPropVariantFromBoolean(data,&pv); + if(SUCCEEDED(hr)) + { + hr=m_pStoreCache->SetValueAndState(key,&pv,PSC_NORMAL); + } + PropVariantClear(&pv); +} void CMythTVProperties::StoreDataInCacheStringVector(PROPERTYKEY key,CAtlStringW &data) { PROPVARIANT pv; Modified: trunk/MythTVReader/PropertyHandler/MythTVProperties.h =================================================================== --- trunk/MythTVReader/PropertyHandler/MythTVProperties.h 2007-07-15 11:47:26 UTC (rev 546) +++ trunk/MythTVReader/PropertyHandler/MythTVProperties.h 2007-07-15 12:20:42 UTC (rev 547) @@ -83,6 +83,7 @@ void StoreDataInCache(PROPERTYKEY key,ULONG data); void StoreDataInCache(PROPERTYKEY key,ULONGLONG data); void StoreDataInCache(PROPERTYKEY key,FILETIME &data); + void StoreDataInCache(PROPERTYKEY key,BOOL data); void StoreDataInCacheStringVector(PROPERTYKEY key,CAtlStringW &data); CComPtr<IStream> m_pStream; Modified: trunk/MythTVReader/PropertyHandler/PropertyHandler.vcproj =================================================================== --- trunk/MythTVReader/PropertyHandler/PropertyHandler.vcproj 2007-07-15 11:47:26 UTC (rev 546) +++ trunk/MythTVReader/PropertyHandler/PropertyHandler.vcproj 2007-07-15 12:20:42 UTC (rev 547) @@ -316,10 +316,6 @@ </FileConfiguration> </File> </Filter> - <File - RelativePath=".\ReadMe.txt" - > - </File> </Files> <Globals> </Globals> Modified: trunk/MythTVReader/PropertyHandler/stdafx.h =================================================================== --- trunk/MythTVReader/PropertyHandler/stdafx.h 2007-07-15 11:47:26 UTC (rev 546) +++ trunk/MythTVReader/PropertyHandler/stdafx.h 2007-07-15 12:20:42 UTC (rev 547) @@ -31,7 +31,6 @@ #define _ATL_CSTRING_EXPLICIT_CONSTRUCTORS // some CString constructors will be explicit - #include "resource.h" #include <atlbase.h> #include <atlcom.h> @@ -39,6 +38,8 @@ #include <shobjidl.h> // IInitializeWithStream, IDestinationStreamFactory #include <propsys.h> // Property System APIs and interfaces #include <propkey.h> // System PROPERTYKEY definitions +#include <propvarutil.h> #include <atltime.h> +#include <atlcoll.h> using namespace ATL; \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |