www.pudn.com > WMACompressor.zip > WmaWriterProfile.cpp
// // THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY // KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE // IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR // PURPOSE. IT CAN BE DISTRIBUTED FREE OF CHARGE AS LONG AS THIS HEADER // REMAINS UNCHANGED. // // Email: yetiicb@hotmail.com // // Copyright (C) 2002-2004 Idael Cardoso. // #include "Stdafx.h" #include "WmaWriterProfile.h" #include#include ".\wmawriterprofile.h" using namespace System; using namespace System::Runtime::InteropServices; using namespace Yeti::MMedia::Wmf; String* WmaWriterProfileManager::GetProfileName(Guid ID) { return (new WmaWriterProfile(ID))->Name; } //ProfileManager ProfileManager::ProfileManager() { m_pProfileManager = new CProfileManager(); } //WmaWriterProfile //Load the first profile as default WmaWriterProfile::WmaWriterProfile() { m_Id = WmaWriterProfileManager::AudioSystemProfiles[0]->Id; m_ProfileData = WmaWriterProfileManager::AudioSystemProfiles[0]->ProfileData; m_Name = WmaWriterProfileManager::AudioSystemProfiles[0]->Name; m_Desc = WmaWriterProfileManager::AudioSystemProfiles[0]->Description; } void WmaWriterProfile::LoadProfile(Guid ID) { m_Id = ID; m_ProfileData = S""; GUID gid; Marshal::StructureToPtr(__box(ID), &gid, false); CProfile* pProfile = dynamic_cast (WmaWriterProfileManager::gProfileManager)->pProfileMager->GetProfile(gid); if (pProfile != NULL) { try { CComBSTR str; str.Attach(pProfile->GetName()); m_Name = Marshal::PtrToStringBSTR((BSTR)str); str.Empty(); str.Attach(pProfile->GetDescription()); m_Desc = Marshal::PtrToStringBSTR((BSTR)str); } __finally { delete pProfile; } } else { throw new ArgumentException("Error creating the profile with this ID", S"ID"); } } void WmaWriterProfile::LoadProfile(String* ProfileData) { const wchar_t __pin* zPdata = PtrToStringChars(ProfileData); CProfile* pProfile = dynamic_cast (WmaWriterProfileManager::gProfileManager)->pProfileMager->GetProfile(zPdata); if (pProfile != NULL) { try { CComBSTR str; m_ProfileData = ProfileData; m_Id = Guid::Empty; str.Attach(pProfile->GetName()); m_Name = Marshal::PtrToStringBSTR((BSTR)str); str.Empty(); str.Attach(pProfile->GetDescription()); m_Desc = Marshal::PtrToStringBSTR((BSTR)str); } __finally { delete pProfile; } } else { throw new ArgumentException("Error creating the profile with this profile data", "ProfileData"); } } WmaWriterProfile::WmaWriterProfile(Guid ID) { LoadProfile(ID); } WmaWriterProfile::WmaWriterProfile(String* ProfileData) { LoadProfile(ProfileData); } WmaWriterProfile::WmaWriterProfile(SerializationInfo* info, StreamingContext context) { Guid Id = Guid::Empty; Id = *dynamic_cast (info->GetValue(S"Profile.ID", __typeof(Guid))); if ( Id == Guid::Empty ) { String* data = dynamic_cast (info->GetValue(S"Profile.ProfileData", __typeof(String))); LoadProfile(data); } else { LoadProfile(Id); } } void WmaWriterProfile::GetObjectData(SerializationInfo* info, StreamingContext context) { info->AddValue(S"Profile.ID", __box(m_Id), __typeof(Guid)); if (m_Id == Guid::Empty) { info->AddValue(S"Profile.ProfileData", m_ProfileData, __typeof(String)); } } CProfile* WmaWriterProfile::get_pProfile() { GUID gid; Marshal::StructureToPtr(__box(m_Id), &gid, false); return static_cast (WmaWriterProfileManager::gProfileManager)->pProfileMager->GetProfile(gid); }