From pouchintv-dev at baysse.fr Sat Nov 1 23:28:46 2008
From: pouchintv-dev at baysse.fr (=?iso-8859-1?q?Liste_utilis=E9e_par_les_d=E9veloppeurs?=)
Date: Sat, 1 Nov 2008 23:28:46 +0100 (CET)
Subject: [Pouchintv-dev] [PouchinTVMod] lolo_32 | r134 - trunk
Message-ID: <20081101222846.5D2895F5ED@mail.baysse.fr>
Author: lolo_32
Date: 2008-11-01 23:28:46 +0100 (sam, 01 nov 2008)
New Revision: 134
Modified:
trunk/chanutils.cpp
trunk/chanutils.h
trunk/xml.cpp
Log:
xml.cpp
* Correction d'un boggue entraînant le retour d'une chaine de caractères de taille suppéieure à la mémoire allouée dans certains cas.
chanutils.cpp, chanutils.h
* Correction d'un boggue dans la gestion des langues des pistes, car la zone mémoire devant contenir le nom de la langue n'était pas effacé.
Modifié: trunk/chanutils.cpp
===================================================================
--- trunk/chanutils.cpp 2008-10-26 19:43:31 UTC (rev 133)
+++ trunk/chanutils.cpp 2008-11-01 22:28:46 UTC (rev 134)
@@ -37,6 +37,11 @@
#include "chanutils.h"
+
+une_piste::une_piste(const une_piste &piste) {
+ pid = piste.pid; type=piste.type;
+ strcpy_s(lang, _countof(lang), piste.lang);
+}
bool liste_pistes::operator == (const liste_pistes & lp) const
{
if (nbr!=lp.nbr)
Modifié: trunk/chanutils.h
===================================================================
--- trunk/chanutils.h 2008-10-26 19:43:31 UTC (rev 133)
+++ trunk/chanutils.h 2008-11-01 22:28:46 UTC (rev 134)
@@ -47,6 +47,10 @@
UINT8 type; // si son : 0 = normal, 1 = AC3; réservé si autres
char lang[8];
+ // Efface le tableau de caractère, car pose des problèmes des fois si pas effacé
+ une_piste() : pid(0), type(0) {ZeroMemory(lang, sizeof(lang)); };
+ une_piste(const une_piste &piste);
+
bool operator == (const une_piste & up) const
{return pid==up.pid && type==up.type/* && strcmp(lang, up.lang)==0*/;}
// (strcmp pas nécessaire pour le moment)
Modifié: trunk/xml.cpp
===================================================================
--- trunk/xml.cpp 2008-10-26 19:43:31 UTC (rev 133)
+++ trunk/xml.cpp 2008-11-01 22:28:46 UTC (rev 134)
@@ -154,11 +154,12 @@
void CXMLNode::getStr(const wchar_t * nom, char * str, size_t size)
{
- wchar_t buffer[64];
- ZeroMemory(buffer, sizeof(buffer));
+ wchar_t *buffer = new wchar_t[size];
+ ZeroMemory(buffer, size);
- getStr(nom, buffer, _countof(buffer));
+ getStr(nom, buffer, size);
WideCharToMultiByte(CP_ACP, 0, buffer, -1, str, size, NULL, NULL);
+ delete buffer;
}
/**
From pouchintv-dev at baysse.fr Sat Nov 8 00:19:58 2008
From: pouchintv-dev at baysse.fr (=?iso-8859-1?q?Liste_utilis=E9e_par_les_d=E9veloppeurs?=)
Date: Sat, 8 Nov 2008 00:19:58 +0100 (CET)
Subject: [Pouchintv-dev] [PouchinTVMod] lolo_32 | r135 - in trunk/Icones: .
Locales
Message-ID: <20081107231958.8CBCD5F329@mail.baysse.fr>
Author: lolo_32
Date: 2008-11-08 00:19:57 +0100 (sam, 08 nov 2008)
New Revision: 135
Added:
trunk/Icones/ARTE HD.bmp
trunk/Icones/France 2 HD.bmp
trunk/Icones/M6HD.bmp
trunk/Icones/TF1 HD.bmp
Modified:
trunk/Icones/Direct 8.bmp
trunk/Icones/Locales/TV RENNES 35.bmp
Log:
Ajout des icônes pour les chaines HD
Ajouté: trunk/Icones/ARTE HD.bmp
===================================================================
(les fichiers binaires diffèrent)
Property changes on: trunk/Icones/ARTE HD.bmp
___________________________________________________________________
Nom : svn:mime-type
+ image/x-ms-bmp
Modifié: trunk/Icones/Direct 8.bmp
===================================================================
(les fichiers binaires diffèrent)
Ajouté: trunk/Icones/France 2 HD.bmp
===================================================================
(les fichiers binaires diffèrent)
Property changes on: trunk/Icones/France 2 HD.bmp
___________________________________________________________________
Nom : svn:mime-type
+ image/x-ms-bmp
Property changes on: trunk/Icones/Locales/TV RENNES 35.bmp
___________________________________________________________________
Nom : svn:mime-type
- application/octet-stream
+ image/x-ms-bmp
Ajouté: trunk/Icones/M6HD.bmp
===================================================================
(les fichiers binaires diffèrent)
Property changes on: trunk/Icones/M6HD.bmp
___________________________________________________________________
Nom : svn:mime-type
+ image/x-ms-bmp
Ajouté: trunk/Icones/TF1 HD.bmp
===================================================================
(les fichiers binaires diffèrent)
Property changes on: trunk/Icones/TF1 HD.bmp
___________________________________________________________________
Nom : svn:mime-type
+ image/x-ms-bmp
From pouchintv-dev at baysse.fr Sun Nov 9 18:11:45 2008
From: pouchintv-dev at baysse.fr (=?iso-8859-1?q?Liste_utilis=E9e_par_les_d=E9veloppeurs?=)
Date: Sun, 9 Nov 2008 18:11:45 +0100 (CET)
Subject: [Pouchintv-dev] [PouchinTVMod] gingko | r136 - trunk
Message-ID: <20081109171145.3A06C5F331@mail.baysse.fr>
Author: gingko
Date: 2008-11-09 18:11:44 +0100 (dim, 09 nov 2008)
New Revision: 136
Modified:
trunk/LCD.cpp
trunk/Pouchin TV.vcproj
trunk/base.cpp
trunk/base.h
trunk/channels.cpp
trunk/graph.cpp
trunk/main.cpp
trunk/recprog.cpp
trunk/res.rc
trunk/search.cpp
trunk/search.h
trunk/settings.cpp
Log:
Amélioration du système d'affichage des erreurs, et en particulier de celles générées
dans le graphe : la fonction "erreur" est maintenant séparée en deux fonctions,
l'une gardant l'ancien nom "erreur", mais se contentant dorénavant d'accumuler les
messages dans un tampon, et l'autre nommée "affiche_erreurs", qui affiche tous les
messages du tampon en une fois, plus éventuellement les siens propres. Ceci évite
la cascade de messages d'alerte qui pouvait auparavant se succéder à chaque sortie
de fonction.
Au passage, les codes d'erreurs numériques sont maintenant décodés en clair (grâce
à une fonction native de DirectShow).
Les messages d'erreurs sont aussi, de manière générale, remplacés par des messages
de style plus "professionnel", et certains nouveaux tests d'erreurs avec messages
ont été ajoutés.
Dans le graphe, la fonction "render_mpeg2" est renommée en "render_psi", ce qui
correspond davantage à son rôle d'extraction des tables PSI.
Dans le dialogue des options (ressources), certains items sont remis en ordre.
Modifié: trunk/LCD.cpp
===================================================================
--- trunk/LCD.cpp 2008-11-07 23:19:57 UTC (rev 135)
+++ trunk/LCD.cpp 2008-11-09 17:11:44 UTC (rev 136)
@@ -108,11 +108,11 @@
ret = lgLcdInit();
if (ret != ERROR_SUCCESS) {
- // Erreur d'initialisation de la librairie
+ // Erreur d'initialisation de la bibliothèque
return false;
}
- // Initialisation de la librairie OK!
+ // Initialisation de la bibliothèque OK !
ZeroMemory(&this->m_connectContext, sizeof(this->m_connectContext));
// Nom de l'affichage dans le LCD
Modifié: trunk/Pouchin TV.vcproj
===================================================================
--- trunk/Pouchin TV.vcproj 2008-11-07 23:19:57 UTC (rev 135)
+++ trunk/Pouchin TV.vcproj 2008-11-09 17:11:44 UTC (rev 136)
@@ -65,7 +65,7 @@
/>
+
+
AddFilter(pFilter, nom);
+
if (FAILED(hr)) {
- pFilter->Release(); // nécessaire ??
- return hr;
+ pFilter->Release();
+ erreur(L"Le filtre \"%s\" n'a pas pu être ajouté au graphe", hr, nom);
}
return hr;
@@ -207,14 +209,14 @@
{
HRESULT hr = pNetworkTuner->QueryInterface(&pBDAControl);
if (FAILED(hr)) {
- erreur(L"IBDA_DeviceControl", hr);
+ erreur(L"L'interface IBDA_DeviceControl n'a pas été trouvée", hr);
return hr;
}
IBDA_Topology * pTop;
hr = pNetworkTuner->QueryInterface(&pTop);
if (FAILED(hr)) {
- myprintf(L"IBDA_Topology : %08X\n", hr);
+ erreur(L"L'interface IBDA_Topology n'a pas été trouvée", hr);
return hr;
}
@@ -262,7 +264,7 @@
IBDA_Topology * pTop;
HRESULT hr = pNetworkTuner->QueryInterface(&pTop);
if (FAILED(hr)) {
- myprintf(L"IBDA_Topology : %08X\n", hr);
+ erreur(L"L'interface IBDA_Topology n'a pas été trouvée", hr);
return hr;
}
@@ -340,20 +342,18 @@
HRESULT hr = pMpeg2Demux->CreateOutputPin(&am, L"video", &pVideoPin);
if (FAILED(hr)) {
- erreur(L"pas créé pin video", hr);
+ erreur(L"La broche vidéo MPEG2 n'a pas pu être créée", hr);
return hr;
}
// le décodeur vidéo
- pVideoCodec = get_filter(MEDIATYPE_Video, MEDIASUBTYPE_MPEG2_VIDEO, filtreMPEG2);
+ hr = get_filter(MEDIATYPE_Video, MEDIASUBTYPE_MPEG2_VIDEO, filtreMPEG2, pVideoCodec);
+ if (SUCCEEDED(hr)) {
+ myprintf(L"Ajout video MPEG2\n");
- if (pVideoCodec != NULL) {
-
- myprintf(L"ajout video\n");
-
hr = pGraph->AddFilter(pVideoCodec, L"Codec vidéo");
if (FAILED(hr)) {
- erreur(L"Codec vidéo non inséré dans le graph", hr);
+ erreur(L"Le codec vidéo MPEG2 \"%s\" n'a pas pu être inséré dans le graphe", hr, filtreMPEG2);
return hr;
}
@@ -361,20 +361,18 @@
hr = cherche_pin(pVideoCodec, PINDIR_INPUT, pPinEntree);
if (SUCCEEDED(hr) && pPinEntree!=NULL) {
- hr = pGraph->ConnectDirect(pVideoPin, pPinEntree, NULL);
- pPinEntree->Release();
+ hr = pGraph->ConnectDirect(pVideoPin, pPinEntree, NULL);
+ pPinEntree->Release();
}
if (FAILED(hr)) {
- erreur(L"Impossible de connecter le demux au codec vidéo", hr);
+ erreur(L"Impossible de connecter le démultiplexeur au codec vidéo MPEG2 \"%s\"", hr, filtreMPEG2);
return hr;
}
-
-
} else {
hr = pGraph->RenderEx(pVideoPin, AM_RENDEREX_RENDERTOEXISTINGRENDERERS, NULL);
if (FAILED(hr)) {
- erreur(L"pas trouvé de codec vidéo", hr);
+ erreur(L"Pas de rendu possible depuis la broche vidéo MPEG2", hr);
return hr;
}
}
@@ -395,31 +393,29 @@
// crée le VMR
hr = create_and_add_filter(MyCLSID_VideoMixingRenderer, L"Mon VMR", pVMR);
-
- if (FAILED(hr) || pVMR == NULL) {
- erreur(L"VMR non inséré", hr);
+ if (FAILED(hr))
return hr;
- }
-
{
MyIVMRFilterConfig * pVMRConfig;
hr = pVMR->QueryInterface(&pVMRConfig);
if (FAILED(hr)) {
- erreur(L"VMR config non dispo", hr);
+ erreur(L"L'interface de configuration VMR n'est pas disponible", hr);
return hr;
}
#if USE_VMR9
- pVMRConfig->SetRenderingMode(MyVMRMode_Windowless);
+ hr = pVMRConfig->SetRenderingMode(MyVMRMode_Windowless);
#else
- pVMRConfig->SetRenderingMode(MyVMRMode_Renderless);
+ hr = pVMRConfig->SetRenderingMode(MyVMRMode_Renderless);
- if (use_vmr_deinterlace)
- pVMRConfig->SetNumberOfStreams(1);
+ if (SUCCEEDED(hr) && use_vmr_deinterlace)
+ hr = pVMRConfig->SetNumberOfStreams(1);
#endif
pVMRConfig->Release();
+ if (FAILED(hr))
+ return hr;
}
#if !USE_VMR9 // Modif R_One - à revérifier
@@ -427,36 +423,43 @@
IVMRSurfaceAllocatorNotify * pNotify;
hr = pVMR->QueryInterface(&pNotify);
if (FAILED(hr)) {
- erreur(L"VMR notify non dispo", hr);
+ erreur(L"L'interface IVMRSurfaceAllocatorNotify n'a pas été trouvée", hr);
return hr;
}
IVMRSurfaceAllocator * pSurfAlloc;
- CoCreateInstance(CLSID_AllocPresenter, NULL,
+ hr = CoCreateInstance(CLSID_AllocPresenter, NULL,
CLSCTX_INPROC_SERVER,
IID_IVMRSurfaceAllocator,
(LPVOID*)&pSurfAlloc);
+ if (FAILED(hr)) {
+ erreur(L"L'interface IVMRSurfaceAllocator n'a pas été trouvée", hr);
+ return hr;
+ }
+
IVMRImagePresenterConfig * pPresConf = NULL;
+
hr = pSurfAlloc->QueryInterface(&pPresConf);
- myprintf(L"IVMRImagePresenterConfig 0x%08x\n", pPresConf);
+ if (FAILED(hr)) {
+ erreur(L"L'interface IVMRImagePresenterConfig n'a pas été trouvée", hr);
+ return hr;
+ }
+
if (is_vista) {
hr = pPresConf->SetRenderingPrefs(RenderPrefs_AllowOffscreen);
} else {
hr = pPresConf->SetRenderingPrefs(RenderPrefs_ForceOverlays | RenderPrefs_DoNotRenderColorKeyAndBorder);
}
+ pPresConf->Release();
if (FAILED(hr)) {
- erreur(L"VMR ImagePresenterConfig non dispo", hr);
+ erreur(L"Échec de SetRenderingPrefs", hr);
return hr;
}
- pPresConf->Release();
-
pNotify->AdviseSurfaceAllocator(0x118218, pSurfAlloc);
-
pSurfAlloc->AdviseNotify(pNotify);
-
}
if (use_vmr_deinterlace) {
@@ -464,69 +467,69 @@
MyIVMRMixerControl * pMixControl;
hr = pVMR->QueryInterface(&pMixControl);
+ if (FAILED(hr)) {
+ erreur(L"L'interface IVMRMixerControl n'a pas été trouvée", hr);
+ return hr;
+ }
+ hr = pMixControl->SetMixingPrefs(MyMixingPrefs);
+ pMixControl->Release();
if (FAILED(hr)) {
- erreur(L"Pas eu le VMRMixerControl :/", hr);
- } else {
+ erreur(L"Échec de SetMixingPrefs", hr);
+ return hr;
+ }
- pMixControl->SetMixingPrefs(MyMixingPrefs);
+ MyIVMRDeinterlaceControl * pDeint;
+ hr = pVMR->QueryInterface(&pDeint);
+ if (FAILED(hr)) {
+ erreur(L"L'interface IVMRDeinterlaceControl n'a pas été trouvée", hr);
+ return hr;
+ }
- pMixControl->Release();
+ DWORD num;
+ MyVMRVideoDesc desc;
- MyIVMRDeinterlaceControl * pDeint;
- hr = pVMR->QueryInterface(&pDeint);
-
- if (FAILED(hr)) {
- erreur(L"Pas eu le DeinterlaceControl :/", hr);
- } else {
-
- DWORD num;
-
- MyVMRVideoDesc desc;
- desc.dwSize = sizeof(MyVMRVideoDesc);
- desc.dwSampleWidth = 720;
- desc.dwSampleHeight = 576;
+ desc.dwSize = sizeof(desc);
+ desc.dwSampleWidth = 720;
+ desc.dwSampleHeight = 576;
#if USE_VMR9
- desc.SampleFormat = VMR9_SampleFieldInterleavedEvenFirst;
- // desc.SampleFormat = VMR9_SampleFieldSingleEven;
+ desc.SampleFormat = VMR9_SampleFieldInterleavedEvenFirst;
+ // desc.SampleFormat = VMR9_SampleFieldSingleEven;
#else // #if USE_VMR9
- desc.SingleFieldPerSample = TRUE;
+ desc.SingleFieldPerSample = TRUE;
#endif // #if USE_VMR9
- // desc.dwFourCC =MAKEFOURCC('Y','V','1','2');
- desc.dwFourCC =MAKEFOURCC('Y','U','Y','2');
- desc.InputSampleFreq.dwNumerator = 25;
- desc.InputSampleFreq.dwDenominator = 1;
- desc.OutputFrameFreq.dwNumerator = 50;
- desc.OutputFrameFreq.dwDenominator = 1;
+ // desc.dwFourCC =MAKEFOURCC('Y','V','1','2');
+ desc.dwFourCC =MAKEFOURCC('Y','U','Y','2');
+ desc.InputSampleFreq.dwNumerator = 25;
+ desc.InputSampleFreq.dwDenominator = 1;
+ desc.OutputFrameFreq.dwNumerator = 50;
+ desc.OutputFrameFreq.dwDenominator = 1;
- hr = pDeint->GetNumberOfDeinterlaceModes(&desc, &num, NULL);
+ hr = pDeint->GetNumberOfDeinterlaceModes(&desc, &num, NULL);
- if (FAILED(hr)) {
- erreur(L"Nombre de modes de désentrelacement non trouvé", hr);
- return hr;
- }
+ if (FAILED(hr)) {
+ erreur(L"Nombre de modes de désentrelacement non trouvé", hr);
+ return hr;
+ }
- myprintf(L"num : %i\n", num);
+ myprintf(L"num : %i\n", num);
- GUID guid[1];
- num = 1;
+ GUID guid[1];
+ num = 1;
- hr = pDeint->GetNumberOfDeinterlaceModes(&desc, &num, guid);
+ hr = pDeint->GetNumberOfDeinterlaceModes(&desc, &num, guid);
- if (FAILED(hr)) {
- erreur(L"Impossible d'avoir le GUID du désentrelacement", hr);
- return hr;
- }
+ if (FAILED(hr)) {
+ erreur(L"Impossible d'avoir le GUID du désentrelacement", hr);
+ return hr;
+ }
- hr = pDeint->SetDeinterlaceMode(0xFFFFFFFF, &guid[0]);
+ hr = pDeint->SetDeinterlaceMode(0xFFFFFFFF, &guid[0]);
+ pDeint->Release();
- if (FAILED(hr)) {
- erreur(L"Impossible de mettre le mode de désentrelacement", hr);
- return hr;
- }
-
- pDeint->Release();
- }
+ if (FAILED(hr)) {
+ erreur(L"Impossible de mettre le mode de désentrelacement", hr);
+ return hr;
}
}
#endif // #if !USE_VMR9
@@ -534,7 +537,7 @@
hr = pVMR->QueryInterface(&pVMRControl);
if (FAILED(hr)) {
- erreur(L"Pas de VMR control !", hr);
+ erreur(L"L'interface de contrôle VMR n'est pas disponible", hr);
return hr;
}
@@ -549,26 +552,24 @@
hr = pVMR->QueryInterface(&pARC);
if (FAILED(hr)) {
- erreur(L"Pas de AspectRatioControl !", hr);
+ erreur(L"L'interface de contrôle du ratio d'aspect n'est pas disponible", hr);
return hr;
}
pARC->SetAspectRatioMode(VMR_ARMODE_LETTER_BOX);
-
pARC->Release();
}
if (pVideoCodec != NULL) {
-
hr = connect_filters(pVideoCodec, pVMR);
if (FAILED(hr)) {
- erreur(L"Impossible de connecter le codec vidéo au VMR.\nC'est probablement l'overlay qui n'est pas disponible.\n\nVeuillez le libérer et relancer l'application", hr);
- return hr;
+ // Ici, on affiche l'erreur mais on ne quitte pas (ça laisse la possibilité d'enregistrer)
+ affiche_erreurs(L"Impossible de connecter le codec vidéo au VMR.\nC'est probablement l'overlay qui n'est pas disponible.\n\nVeuillez le libérer et relancer l'application", hr);
}
} else {
- erreur(L"pas trouvé de codec vidéo");
+ erreur(L"Il n'y a pas de codec vidéo disponible", hr);
return hr;
}
@@ -605,54 +606,51 @@
HRESULT hr = pMpeg2Demux->CreateOutputPin(&am, L"son", &pSoundPin);
if (FAILED(hr)) {
- erreur(L"pas créé pin son", hr);
+ erreur(L"La broche audio MPEG2 n'a pas pu être créée", hr);
return hr;
}
// add direct sound
hr = create_and_add_filter(CLSID_DSoundRender, L"Direct sound", pDSound);
- if (FAILED(hr) || pDSound == NULL) {
- erreur(L"Direct sound pas ajouté", hr);
+ if (FAILED(hr))
return hr;
- }
// le décodeur audio
- pAudioCodec = get_filter(MEDIATYPE_Audio, MEDIASUBTYPE_MPEG2_AUDIO, filtreAudio);
+ hr = get_filter(MEDIATYPE_Audio, MEDIASUBTYPE_MPEG2_AUDIO, filtreAudio, pAudioCodec);
+ if (SUCCEEDED(hr)) {
- if (pAudioCodec != NULL) {
-
myprintf(L"ajout audio\n");
hr = pGraph->AddFilter(pAudioCodec, L"Codec audio");
if (FAILED(hr)) {
- erreur(L"Codec audio non inséré dans le graph", hr);
- return 1;
+ erreur(L"Le codec audio MPEG2 \"%s\" n'a pas pu être inséré dans le graphe", hr, filtreAudio);
+ return hr;
}
IPin * pPinEntree = NULL;
hr = cherche_pin(pAudioCodec, PINDIR_INPUT, pPinEntree);
if (SUCCEEDED(hr) && pPinEntree != NULL) {
- hr = pGraph->ConnectDirect(pSoundPin, pPinEntree, NULL);
- pPinEntree->Release();
+ hr = pGraph->ConnectDirect(pSoundPin, pPinEntree, NULL);
+ pPinEntree->Release();
}
if (FAILED(hr)) {
- erreur(L"Impossible de connecter le demux au codec audio", hr);
+ erreur(L"Impossible de connecter le démultiplexeur au codec audio MPEG2 \"%s\"", hr, filtreAudio);
return hr;
}
hr = connect_filters(pAudioCodec, pDSound);
if (FAILED(hr)) {
- erreur(L"connec Codec audio", hr);
+ erreur(L"Impossible de connecter le Codec audio MPEG2 \"%s\" au filtre de rendu DirectSound", hr, filtreAudio);
return hr;
}
} else {
hr = pGraph->RenderEx(pSoundPin, AM_RENDEREX_RENDERTOEXISTINGRENDERERS, NULL);
if (FAILED(hr)) {
- erreur(L"pas render son", hr);
+ erreur(L"Pas de rendu possible depuis la broche audio MPEG2", hr);
return hr;
}
}
@@ -693,28 +691,25 @@
HRESULT hr = pMpeg2Demux->CreateOutputPin(&am, L"ac3", &pAc3Pin);
if (FAILED(hr)) {
- erreur(L"pas créé pin ac3", hr);
+ erreur(L"La broche audio AC3 n'a pas pu être créée", hr);
return hr;
}
// add direct sound
hr = create_and_add_filter(CLSID_DSoundRender, L"Direct sound le retour", pDSoundAc3);
- if (FAILED(hr) || pDSoundAc3 == NULL) {
- erreur(L"Direct sound le retour not added", hr);
+ if (FAILED(hr))
return hr;
- }
// le décodeur ac3
- pAc3Codec = get_filter(MEDIATYPE_Audio, MEDIASUBTYPE_DOLBY_AC3, filtreAc3);
+ hr = get_filter(MEDIATYPE_Audio, MEDIASUBTYPE_DOLBY_AC3, filtreAc3, pAc3Codec);
+ if (SUCCEEDED(hr)) {
- if (pAc3Codec != NULL) {
-
myprintf(L"ajout ac3\n");
hr = pGraph->AddFilter(pAc3Codec, L"Codec ac3");
if (FAILED(hr)) {
- erreur(L"Codec AC3 non inséré dans le graph", hr);
+ erreur(L"Le codec audio AC3 \"%s\" n'a pas pu être inséré dans le graphe", hr, filtreAc3);
return hr;
}
@@ -722,25 +717,25 @@
hr = cherche_pin(pAc3Codec, PINDIR_INPUT, pPinEntree);
if (SUCCEEDED(hr) && pPinEntree!=NULL) {
- hr = pGraph->ConnectDirect(pAc3Pin, pPinEntree, NULL);
- pPinEntree->Release();
+ hr = pGraph->ConnectDirect(pAc3Pin, pPinEntree, NULL);
+ pPinEntree->Release();
}
if (FAILED(hr)) {
- erreur(L"Impossible de connecter le demux au codec AC3", hr);
+ erreur(L"Impossible de connecter le démultiplexeur au codec AC3 \"%s\"", hr, filtreAc3);
return hr;
}
hr = connect_filters(pAc3Codec, pDSoundAc3);
if (FAILED(hr)) {
- erreur(L"connec Codec audio", hr);
+ erreur(L"Impossible de connecter le Codec audio AC3 \"%s\" au filtre de rendu DirectSound", hr, filtreAc3);
return hr;
}
} else {
hr = pGraph->RenderEx(pAc3Pin, AM_RENDEREX_RENDERTOEXISTINGRENDERERS, NULL);
if (FAILED(hr)) {
- erreur(L"pas render son", hr);
+ erreur(L"Pas de rendu possible depuis la broche audio AC3", hr);
return hr;
}
}
@@ -753,7 +748,7 @@
}
-static HRESULT render_mpeg2(IMpeg2Demultiplexer * pMpeg2Demux)
+static HRESULT render_psi(IMpeg2Demultiplexer * pMpeg2Demux)
{
IPin * pDataPin;
@@ -771,7 +766,7 @@
HRESULT hr = pMpeg2Demux->CreateOutputPin(&am, L"data", &pDataPin);
if (FAILED(hr)) {
- erreur(L"pas créé pin data", hr);
+ erreur(L"La broche PSI n'a pas pu être créée", hr);
return hr;
}
@@ -780,17 +775,15 @@
IBaseFilter * pMpeg2Filter = NULL;
hr = create_and_add_filter(__uuidof(Mpeg2Data), L"MPEG2 data", pMpeg2Filter);
- if (FAILED(hr) || pMpeg2Filter == NULL) {
- erreur(L"MPEG2 data pas inséré", hr);
+ if (FAILED(hr))
return hr;
- }
// query MPEG-2 Sections and Tables Filter
hr = pMpeg2Filter->QueryInterface(&pMpeg2Data);
if (FAILED(hr)) {
- erreur(L"pas eu le mpeg2data", hr);
+ erreur(L"L'interface d'accès aux tables PSI n'a pas été trouvée", hr);
return hr;
}
@@ -803,7 +796,7 @@
}
if (FAILED(hr)) {
- erreur(L"Impossible de connecter le demux au mpeg2data", hr);
+ erreur(L"Impossible de connecter le démultiplexeur au filtre PSI", hr);
return hr;
}
@@ -833,7 +826,7 @@
HRESULT hr = pMpeg2Demux->CreateOutputPin(&am, L"epg", &pEpgPin);
if (FAILED(hr)) {
- erreur(L"pas créé pin epg", hr);
+ erreur(L"La broche EPG n'a pas pu être créée", hr);
return hr;
}
@@ -842,9 +835,13 @@
CLSID clsid = {5, 6, 7, 8, 9, 10, 11, 12, 13};
CEPGFilter * pEPGFilter = new CEPGFilter(clsid, &hr);
+ if (FAILED(hr)) {
+ erreur(L"Le filtre EPG n'a pas pu être créé", hr);
+ return hr;
+ }
hr = pGraph->AddFilter(pEPGFilter, L"Mon filtre EPG");
if (FAILED(hr)) {
- erreur(L"pas ajouté filtre EPG au graph", hr);
+ erreur(L"Le filtre EPG n'a pas pu être ajouté au graphe", hr);
return hr;
}
@@ -852,7 +849,7 @@
hr = cherche_pin(pEPGFilter, PINDIR_INPUT, pPinEntree);
if (FAILED(hr) || pEPGFilter == NULL) {
- erreur(L"pas trouvé pin entrée", hr);
+ erreur(L"La broche d'entrée EPG n'a pas été trouvée", hr);
return hr;
}
@@ -860,7 +857,7 @@
pPinEntree->Release();
if (FAILED(hr)) {
- erreur(L"pas connecté pin entrée", hr);
+ erreur(L"La broche d'entrée EPG n'a pas pu être connectée", hr);
return hr;
}
}
@@ -896,7 +893,7 @@
HRESULT hr = pMpeg2Demux->CreateOutputPin(&am, L"pmt", &pPmtPin);
if (FAILED(hr)) {
- erreur(L"pas créé pin pmt", hr);
+ erreur(L"La broche PMT n'a pas pu être créée", hr);
return hr;
}
@@ -906,13 +903,13 @@
CPMTFilter * pPMTFilter = new CPMTFilter(clsid, &hr);
if (FAILED(hr) || pPMTFilter == NULL) {
- erreur(L"pas pu créer filtre PMT", hr);
+ erreur(L"Le filtre PMT n'a pas pu être créé", hr);
return hr;
}
hr = pGraph->AddFilter(pPMTFilter, L"Mon filtre PMT");
if (FAILED(hr)) {
- erreur(L"pas ajouté PMT filtre au graph", hr);
+ erreur(L"Le filtre PMT n'a pas pu être ajouté au graphe", hr);
return hr;
}
@@ -921,7 +918,7 @@
hr = cherche_pin(pPMTFilter, PINDIR_INPUT, pPinEntree);
if (FAILED(hr) || pPMTFilter == NULL)
{
- erreur(L"pas trouvé pin entrée", hr);
+ erreur(L"La broche d'entrée PMT n'a pas été trouvée", hr);
return hr;
}
@@ -929,7 +926,7 @@
pPinEntree->Release();
if (FAILED(hr)) {
- erreur(L"pas connecté pin entrée", hr);
+ erreur(L"La broche d'entrée PMT n'a pas pu être connectée", hr);
return hr;
}
@@ -954,37 +951,37 @@
hr = pDemux->QueryInterface(&pMpeg2Demux);
if (FAILED(hr)) {
- erreur(L"Demux MPEG2 non valide !", hr);
+ erreur(L"L'interface du démultiplexeur n'a pas été trouvée", hr);
return hr;
}
if (FAILED(hr = render_mp2v(pMpeg2Demux))) {
- erreur(L"Erreur lors du rendu du pin mp2v", hr);
+ erreur(L"Erreur lors du rendu de la broche vidéo MPEG2", hr);
return hr;
}
if (FAILED(hr = render_son(pMpeg2Demux))) {
- erreur(L"Erreur lors du rendu du pin son", hr);
+ erreur(L"Erreur lors du rendu de la broche audio MPEG2", hr);
return hr;
}
if (FAILED(hr = render_ac3(pMpeg2Demux))) {
- erreur(L"Erreur lors du rendu du pin ac3", hr);
+ erreur(L"Erreur lors du rendu de la broche audio AC3", hr);
return hr;
}
- if (FAILED(hr = render_mpeg2(pMpeg2Demux))) {
- erreur(L"Erreur lors du rendu du pin mpeg2", hr);
+ if (FAILED(hr = render_psi(pMpeg2Demux))) {
+ erreur(L"Erreur lors du rendu de la broche PSI", hr);
return hr;
}
if (FAILED(hr = render_epgfilter(pMpeg2Demux))) {
- erreur(L"Erreur lors du rendu du pin epg", hr);
+ erreur(L"Erreur lors du rendu de la broche EPG", hr);
return hr;
}
if (FAILED(hr = render_pmtfilter(pMpeg2Demux))) {
- erreur(L"Erreur lors du rendu du pin pmt", hr);
+ erreur(L"Erreur lors du rendu de la broche PMT", hr);
return hr;
}
@@ -1003,7 +1000,7 @@
HRESULT hr = CoCreateInstance(CLSID_FilterGraph, NULL, CLSCTX_INPROC_SERVER,
IID_IFilterGraph2, (void **)&pGraph);
if (FAILED(hr) ) {
- erreur(L"Pas réussi à créer le graph DirectShow !", hr);
+ erreur(L"Pas réussi à créer le graphe DirectShow !", hr);
return hr;
}
@@ -1018,7 +1015,7 @@
#if EXPORT_GRAPH
hr = AddToRot();
if (FAILED(hr)) {
- erreur(L"échec de l'exportation du graphe", hr);
+ erreur(L"Échec de l'exportation du graphe", hr);
return hr;
}
#endif // #if EXPORT_GRAPH
@@ -1027,9 +1024,11 @@
CLSID clsid = {1,2,3,4,5,6,7,8,9,10,11};
IBaseFilter * pNetworkProvider = new CNetworkProvider(clsid);
- hr = pGraph->AddFilter(pNetworkProvider, L"Fake");
+
+ if (pNetworkProvider)
+ hr = pGraph->AddFilter(pNetworkProvider, L"Fake");
if (FAILED(hr)) {
- erreur(L"ajout du network provider ratée !!!", hr);
+ erreur(L"Échec de l'insertion du filtre \"CNetworkProvider\"", hr);
return hr;
}
@@ -1043,27 +1042,27 @@
hr = pGraph->AddFilter(pNetworkTuner, L"Network Tuner");
if (FAILED(hr)) {
- erreur(L"Tuner pas inséré", hr);
+ erreur(L"Échec de l'insertion du filtre Tuner", hr);
return hr;
}
hr = pGraph->AddFilter(pReceiverComponent, L"Receiver Component");
if (FAILED(hr)) {
- erreur(L"Récepteur pas inséré", hr);
+ erreur(L"Échec de l'insertion du filtre Récepteur", hr);
return hr;
}
// connect Tuner
hr = connect_filters(pNetworkProvider, pNetworkTuner);
if (FAILED(hr)) {
- erreur(L"Tuner TNT non compatible, veuillez effacer config.ini et redémarrer", hr);
+ erreur(L"Tuner TNT non compatible, veuillez effacer \"config.ini\" et redémarrer", hr);
return hr;
}
// connect Receiver
hr = connect_filters(pNetworkTuner, pReceiverComponent);
if (FAILED(hr)) {
- erreur(L"Récepteur TNT non compatible, veuillez effacer config.ini et redémarrer", hr);
+ erreur(L"Récepteur TNT non compatible, veuillez effacer \"config.ini\" et redémarrer", hr);
return hr;
}
@@ -1077,13 +1076,13 @@
// connect USB
hr = pGraph->AddFilter(pNetworkTuner, L"Tuner USB");
if (FAILED(hr)) {
- erreur(L"Tuner USB pas inséré", hr);
+ erreur(L"Échec de l'insertion du filtre Tuner USB", hr);
return hr;
}
hr = connect_filters(pNetworkProvider, pNetworkTuner);
if (FAILED(hr)) {
- erreur(L"Tuner USB non compatible, veuillez effacer config.ini et redémarrer", hr);
+ erreur(L"Tuner USB non compatible, veuillez effacer \"config.ini\" et redémarrer", hr);
return hr;
}
@@ -1097,13 +1096,13 @@
hr = getFrequencyFilter(pNetworkTuner);
if (FAILED(hr) || pBDAFreq == NULL) {
- erreur(L"Pas trouvé l'interface pour changer de fréquence", hr);
+ erreur(L"L'interface de changement de fréquence n'a pas été trouvée", hr);
return hr;
}
hr = getSignalStatistics(pNetworkTuner);
if (FAILED(hr) || pStats == NULL) {
- erreur(L"Pas trouvé l'interface pour avoir la qualité du signal", hr);
+ erreur(L"L'interface de qualité du signal n'a pas été trouvée", hr);
return hr;
}
@@ -1111,24 +1110,21 @@
{
// connect 3
- wchar_t nom[20];
-
IBaseFilter *filtrePrec = pAvantDemux;
filtrePrec->AddRef();
IBaseFilter * pGrabber;
for (int i=0; iRelease();
-
}
// fin des recherches, ajoute tout dans le graph
@@ -1165,7 +1157,7 @@
hr = cree_and_render_pins();
if (FAILED(hr)) {
- erreur(L"Erreur lors de la création du graph", hr);
+ erreur(L"Erreur lors de la création du graphe", hr);
return hr;
}
Modifié: trunk/main.cpp
===================================================================
--- trunk/main.cpp 2008-11-07 23:19:57 UTC (rev 135)
+++ trunk/main.cpp 2008-11-09 17:11:44 UTC (rev 136)
@@ -962,7 +962,7 @@
if (Canaux.size() > 0) {
restaure_chaine(sidChaineConfig);
} else {
- erreur(L"Aucune chaîne n'est dans le fichier");
+ affiche_erreurs(L"Aucune chaîne n'est dans le fichier");
update_all_menus(hMainWnd);
}
@@ -1202,7 +1202,7 @@
static void create_property_dialog(IBaseFilter * pFilter, LPCOLESTR nom)
{
if (pFilter == NULL) {
- erreur(L"Il faut d'abord configurer un filtre et redémarrer l'application");
+ affiche_erreurs(L"Il faut d'abord configurer un filtre et redémarrer l'application");
return;
}
@@ -1210,7 +1210,7 @@
HRESULT hr = pFilter->QueryInterface(&pPages);
if (FAILED(hr)) {
- erreur(L"Ce filtre n'a pas de page de propriétés", hr);
+ affiche_erreurs(L"Ce filtre n'a pas de page de propriétés", hr);
return;
}
@@ -1244,7 +1244,7 @@
CoTaskMemFree(caGUID.pElems);
if (FAILED(hr)) {
- erreur(L"Erreur lors de la création de la page de propriétés", hr);
+ affiche_erreurs(L"Erreur lors de la création de la page de propriétés", hr);
}
}
@@ -2781,7 +2781,7 @@
HRESULT hr = CoInitializeEx(NULL,COINIT_MULTITHREADED);
if (FAILED(hr)) {
- erreur(L"Impossible d'initialiser la librairie COM.");
+ affiche_erreurs(L"Impossible d'initialiser la bibliothèque COM.");
return hr;
}
@@ -2870,17 +2870,17 @@
if (!config_ok) {
if (drivers_dialog()!=IDOK) {
- erreur(L"Configuration annulée.\nLe logiciel ne peut pas être exécuté.");
+ affiche_erreurs(L"Configuration annulée.\nLe logiciel ne peut pas être exécuté.");
return -1;
}
config_ok = check_config();
}
if (!config_ok) {
- erreur(L"Configuration incorrecte.\nVeuillez renseigner correctement tous les champs.");
+ affiche_erreurs(L"Configuration incorrecte.\nVeuillez renseigner correctement tous les champs.");
continue;
} else if (FAILED(hr = InitDshow())) {
clean_dshow();
- erreur(L"Erreur lors de l'initialisation.\nVeuillez corriger la configuration.", hr);
+ affiche_erreurs(L"Erreur lors de l'initialisation.\nVeuillez corriger la configuration.", hr);
config_ok = false;
}
} while (!config_ok);
Modifié: trunk/recprog.cpp
===================================================================
--- trunk/recprog.cpp 2008-11-07 23:19:57 UTC (rev 135)
+++ trunk/recprog.cpp 2008-11-09 17:11:44 UTC (rev 136)
@@ -210,7 +210,7 @@
wchar_t buffer[256];
if (ixChaine<0) {
- erreur(L"La chaîne est incorrecte");
+ affiche_erreurs(L"La chaîne est incorrecte");
return false;
}
@@ -219,27 +219,27 @@
long duree = DiffTime(fin, debut);
if (duree < 0) {
- erreur(L"Le programme commence après avoir fini !");
+ affiche_erreurs(L"Le programme commence après avoir fini !");
return false;
}
if (duree == 0) {
- erreur(L"La durée de l'enregistrement est nulle !");
+ affiche_erreurs(L"La durée de l'enregistrement est nulle !");
return false;
}
if (duree > 12*60*60*1000) {
- erreur(L"La durée de l'enregistrement dépasse 12 heures !");
+ affiche_erreurs(L"La durée de l'enregistrement dépasse 12 heures !");
return false;
}
if (DiffTime(fin, localtime) < 0) {
- erreur(L"L'heure de fin du programme est dépassée !");
+ affiche_erreurs(L"L'heure de fin du programme est dépassée !");
return false;
}
if (nom[0] == 0) {
- erreur(L"Veuillez donner un nom à ce programme");
+ affiche_erreurs(L"Veuillez donner un nom à ce programme");
return false;
}
@@ -251,7 +251,7 @@
if (!modif) {
if (strcmp(prog_verif.nom, nom) == 0) {
- erreur(L"Ce nom est déjà utilisé");
+ affiche_erreurs(L"Ce nom est déjà utilisé");
return false;
}
}
@@ -264,7 +264,7 @@
swprintf_s(buffer, _countof(buffer),
L"Chevauchement des horaires avec \"%S\", qui concerne la même chaîne !",
prog_verif.nom);
- erreur(buffer);
+ affiche_erreurs(buffer);
return false;
}
@@ -273,7 +273,7 @@
swprintf_s(buffer, _countof(buffer),
L"Chevauchement des horaires avec \"%S\" sur %S, qui ne partage pas le même multiplex !",
prog_verif.nom, canal.nom);
- erreur(buffer);
+ affiche_erreurs(buffer);
return false;
}
}
Modifié: trunk/res.rc
===================================================================
--- trunk/res.rc 2008-11-07 23:19:57 UTC (rev 135)
+++ trunk/res.rc 2008-11-09 17:11:44 UTC (rev 136)
@@ -176,12 +176,12 @@
GROUPBOX "Avancé",IDC_STATIC,7,85,276,24
CONTROL "Permettre l'enregistrement intégral du multiplex courant",IDC_ALLOW_STREAM_RECORD,
"Button",BS_AUTOCHECKBOX | WS_TABSTOP,14,95,262,10
- GROUPBOX "Divers",IDC_STATIC,7,178,276,29
- CONTROL "Afficher le nom de l'émission sous MSN",IDC_MSN,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,14,190,262,10
GROUPBOX "Nom des enregistrements",IDC_STATIC,7,110,276,67
EDITTEXT IDC_NOM_REC,14,121,261,12,ES_AUTOHSCROLL
LTEXT "%c = chaine\n%e = nom de l'enregistrement",IDC_STATIC,14,135,262,18
LTEXT "%a = année\t\t%m = mois\t\t%j = jour\n%h = heure\t\t%M = minute\t\t%s = secondes",IDC_STATIC,14,158,262,17
+ GROUPBOX "Divers",IDC_STATIC,7,178,276,29
+ CONTROL "Afficher le nom de l'émission sous MSN",IDC_MSN,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,14,190,262,10
END
IDD_FOLDERS DIALOGEX 0, 0, 290, 214
Modifié: trunk/search.cpp
===================================================================
--- trunk/search.cpp 2008-11-07 23:19:57 UTC (rev 135)
+++ trunk/search.cpp 2008-11-09 17:11:44 UTC (rev 136)
@@ -132,7 +132,7 @@
}
-IBaseFilter * get_filter(GUID type, GUID subtype, wchar_t * nom)
+HRESULT get_filter(GUID type, GUID subtype, LPCWSTR nom, IBaseFilter * & pFilter)
{
myprintf(L"get_filter: type={%08x-%04x-%04x-%012x}\n", type.Data1, type.Data2, type.Data3, type.Data4);
myprintf(L"\tsubtype={%08x-%04x-%04x-%012x}\n", subtype.Data1, subtype.Data2, subtype.Data3, subtype.Data4);
@@ -140,11 +140,13 @@
IFilterMapper2 * pMapper;
+ pFilter = NULL;
+
HRESULT hr = CoCreateInstance(CLSID_FilterMapper2, NULL, CLSCTX_INPROC,
IID_IFilterMapper2, (void **)&pMapper);
if (FAILED(hr)) {
myprintf(L"get_filter, 1, hr=0x%08x\n", hr);
- return NULL;
+ return hr;
}
GUID arrayInTypes[2];
@@ -173,13 +175,12 @@
if (FAILED(hr)) {
myprintf(L"get_filter, 2, hr=0x%08x\n", hr);
pMapper->Release();
- return NULL;
+ return hr;
}
// Enumerate the monikers.
IMoniker *pMoniker;
ULONG cFetched;
- IBaseFilter *pFilter = NULL;
while (pFilter == NULL && pEnum->Next(1, &pMoniker, &cFetched) == S_OK) {
IPropertyBag * pPropBag;
@@ -208,7 +209,7 @@
pEnum->Release();
pMapper->Release();
- return pFilter;
+ return hr;
}
// 1er pin non connecté
Modifié: trunk/search.h
===================================================================
--- trunk/search.h 2008-11-07 23:19:57 UTC (rev 135)
+++ trunk/search.h 2008-11-09 17:11:44 UTC (rev 136)
@@ -31,7 +31,7 @@
HRESULT cherche_pin(IBaseFilter * pFilter, PIN_DIRECTION dir, IPin * & result);
void search_filters(GUID type, GUID subtype, HWND hItm);
-IBaseFilter * get_filter(GUID type, GUID subtype, wchar_t * nom);
+HRESULT get_filter(GUID type, GUID subtype, LPCWSTR nom, IBaseFilter * & pFilter);
HRESULT remplit_tuners(GUID guid, HWND hItm);
IBaseFilter * get_tuner(GUID guid, wchar_t * nom);
Modifié: trunk/settings.cpp
===================================================================
--- trunk/settings.cpp 2008-11-07 23:19:57 UTC (rev 135)
+++ trunk/settings.cpp 2008-11-09 17:11:44 UTC (rev 136)
@@ -288,7 +288,7 @@
switch (scanState) {
case ss_idle:
if (nomVille[0]==0) {
- erreur(L"Veuillez d'abord sélectionner une ville");
+ affiche_erreurs(L"Veuillez d'abord sélectionner une ville");
break;
}
zappe_index(-1);
@@ -425,7 +425,7 @@
if (Canaux.empty()) {
static LPCWSTR msg_aucune = L"Aucune chaîne n'a été trouvée";
- erreur(msg_aucune);
+ affiche_erreurs(msg_aucune);
AddLineToList(hListItem, msg_aucune);
} else {
do_init_vmr();
From pouchintv-dev at baysse.fr Sun Nov 9 20:48:50 2008
From: pouchintv-dev at baysse.fr (=?iso-8859-1?q?Liste_utilis=E9e_par_les_d=E9veloppeurs?=)
Date: Sun, 9 Nov 2008 20:48:50 +0100 (CET)
Subject: [Pouchintv-dev] [PouchinTVMod] gingko | r137 - trunk
Message-ID: <20081109194850.930125F331@mail.baysse.fr>
Author: gingko
Date: 2008-11-09 20:48:50 +0100 (dim, 09 nov 2008)
New Revision: 137
Modified:
trunk/base.h
trunk/graph.cpp
trunk/graph.h
Log:
Utilisation d'une macro de concaténation pour produire certains changements
d'identificateurs entre le VMR7 et le VMR9, évitant ainsi de devoir
définir un nouveau symbole pour chaque nouvel identificateur modifié
qu'on souhaite utiliser.
Modifié: trunk/base.h
===================================================================
--- trunk/base.h 2008-11-09 17:11:44 UTC (rev 136)
+++ trunk/base.h 2008-11-09 19:48:50 UTC (rev 137)
@@ -67,9 +67,7 @@
#include "resource.h"
// Décommenter si on veut afficher la console de debugging :
-//#undef USE_CONSOLE
//#define USE_CONSOLE 1
-//#define USE_CONSOLE -1
//
// On peut aussi mettre USE_CONSOLE=-1, afin d'envoyer les messages
// d'erreur vers la fonction OutputDebugString, pour ensuite les
@@ -125,56 +123,26 @@
#if USE_VMR9
-#define MyIVMRWindowlessControl IVMRWindowlessControl9
-#define MyIID_IVMRWindowlessControl IID_IVMRWindowlessControl9
-#define MyCLSID_VideoMixingRenderer CLSID_VideoMixingRenderer9
+ #define MyV(a) a ## 9
-#define MyIVMRFilterConfig IVMRFilterConfig9
-#define MyIID_IVMRFilterConfig IID_IVMRFilterConfig9
+ #define MyVMRVideoDesc VMR9VideoDesc
-#define MyIVMRMixerControl IVMRMixerControl9
-#define MyIID_IVMRMixerControl IID_IVMRMixerControl9
+ #define MyVMRMode_Windowless VMR9Mode_Windowless
+ #define MyVMRMode_Renderless VMR9Mode_Renderless
-#define MyIVMRDeinterlaceControl IVMRDeinterlaceControl9
-#define MyIID_IVMRDeinterlaceControl IID_IVMRDeinterlaceControl9
+ #define MyMIXINGPREFS (MixerPref9_NoDecimation | MixerPref9_BiLinearFiltering | MixerPref9_RenderTargetYUV)
-#define MyIVMRAspectRatioControl IVMRAspectRatioControl9
-#define MyIID_IVMRAspectRatioControl IID_IVMRAspectRatioControl9
-
-#define MyVMRVideoDesc VMR9VideoDesc
-
-#define MyVMRMode_Windowless VMR9Mode_Windowless
-
-#define MyVMRMode_Renderless VMR9Mode_Renderless
-
-#define MyMixingPrefs (MixerPref9_NoDecimation | MixerPref9_BiLinearFiltering | MixerPref9_RenderTargetYUV)
-
#else // #if USE_VMR9
-#define MyIVMRWindowlessControl IVMRWindowlessControl
-#define MyIID_IVMRWindowlessControl IID_IVMRWindowlessControl
-#define MyCLSID_VideoMixingRenderer CLSID_VideoMixingRenderer
+ #define MyV(a) a
-#define MyIVMRFilterConfig IVMRFilterConfig
-#define MyIID_IVMRFilterConfig IID_IVMRFilterConfig
+ #define MyVMRVideoDesc VMRVideoDesc
-#define MyIVMRMixerControl IVMRMixerControl
-#define MyIID_IVMRMixerControl IID_IVMRMixerControl
+ #define MyVMRMode_Windowless VMRMode_Windowless
+ #define MyVMRMode_Renderless VMRMode_Renderless
-#define MyIVMRDeinterlaceControl IVMRDeinterlaceControl
-#define MyIID_IVMRDeinterlaceControl IID_IVMRDeinterlaceControl
+ #define MyMIXINGPREFS (MixerPref_NoDecimation | MixerPref_BiLinearFiltering | MixerPref_RenderTargetYUV)
-#define MyIVMRAspectRatioControl IVMRAspectRatioControl
-#define MyIID_IVMRAspectRatioControl IID_IVMRAspectRatioControl
-
-#define MyVMRVideoDesc VMRVideoDesc
-
-#define MyVMRMode_Windowless VMRMode_Windowless
-
-#define MyVMRMode_Renderless VMRMode_Renderless
-
-#define MyMixingPrefs (MixerPref_NoDecimation | MixerPref_BiLinearFiltering | MixerPref_RenderTargetYUV)
-
#endif // #if USE_VMR9
// Macros utilitaires pour améliorer la lisibilité du code :
Modifié: trunk/graph.cpp
===================================================================
--- trunk/graph.cpp 2008-11-09 17:11:44 UTC (rev 136)
+++ trunk/graph.cpp 2008-11-09 19:48:50 UTC (rev 137)
@@ -40,7 +40,7 @@
IFilterGraph2 * pGraph = NULL;
IMediaControl * pControl = NULL;
-MyIVMRWindowlessControl * pVMRControl = NULL;
+MyV(IVMRWindowlessControl) * pVMRControl = NULL;
IBaseFilter * pDemux = NULL;
@@ -392,12 +392,12 @@
// crée le VMR
- hr = create_and_add_filter(MyCLSID_VideoMixingRenderer, L"Mon VMR", pVMR);
+ hr = create_and_add_filter(MyV(CLSID_VideoMixingRenderer), L"Video Mixing Renderer", pVMR);
if (FAILED(hr))
return hr;
{
- MyIVMRFilterConfig * pVMRConfig;
+ MyV(IVMRFilterConfig) * pVMRConfig;
hr = pVMR->QueryInterface(&pVMRConfig);
if (FAILED(hr)) {
erreur(L"L'interface de configuration VMR n'est pas disponible", hr);
@@ -420,18 +420,18 @@
#if !USE_VMR9 // Modif R_One - à revérifier
{
- IVMRSurfaceAllocatorNotify * pNotify;
+ MyV(IVMRSurfaceAllocatorNotify) * pNotify;
hr = pVMR->QueryInterface(&pNotify);
if (FAILED(hr)) {
erreur(L"L'interface IVMRSurfaceAllocatorNotify n'a pas été trouvée", hr);
return hr;
}
- IVMRSurfaceAllocator * pSurfAlloc;
+ MyV(IVMRSurfaceAllocator) * pSurfAlloc = NULL;
hr = CoCreateInstance(CLSID_AllocPresenter, NULL,
CLSCTX_INPROC_SERVER,
- IID_IVMRSurfaceAllocator,
+ MyV(IID_IVMRSurfaceAllocator),
(LPVOID*)&pSurfAlloc);
if (FAILED(hr)) {
@@ -439,7 +439,7 @@
return hr;
}
- IVMRImagePresenterConfig * pPresConf = NULL;
+ MyV(IVMRImagePresenterConfig) * pPresConf = NULL;
hr = pSurfAlloc->QueryInterface(&pPresConf);
if (FAILED(hr)) {
@@ -464,7 +464,7 @@
if (use_vmr_deinterlace) {
- MyIVMRMixerControl * pMixControl;
+ MyV(IVMRMixerControl) * pMixControl;
hr = pVMR->QueryInterface(&pMixControl);
if (FAILED(hr)) {
@@ -472,14 +472,14 @@
return hr;
}
- hr = pMixControl->SetMixingPrefs(MyMixingPrefs);
+ hr = pMixControl->SetMixingPrefs(MyMIXINGPREFS);
pMixControl->Release();
if (FAILED(hr)) {
erreur(L"Échec de SetMixingPrefs", hr);
return hr;
}
- MyIVMRDeinterlaceControl * pDeint;
+ MyV(IVMRDeinterlaceControl) * pDeint;
hr = pVMR->QueryInterface(&pDeint);
if (FAILED(hr)) {
erreur(L"L'interface IVMRDeinterlaceControl n'a pas été trouvée", hr);
@@ -548,7 +548,7 @@
#endif
{
- MyIVMRAspectRatioControl * pARC;
+ MyV(IVMRAspectRatioControl) * pARC;
hr = pVMR->QueryInterface(&pARC);
if (FAILED(hr)) {
Modifié: trunk/graph.h
===================================================================
--- trunk/graph.h 2008-11-09 17:11:44 UTC (rev 136)
+++ trunk/graph.h 2008-11-09 19:48:50 UTC (rev 137)
@@ -42,7 +42,7 @@
extern IBaseFilter * pNetworkTuner;
extern IBaseFilter * pReceiverComponent;
-extern MyIVMRWindowlessControl * pVMRControl;
+extern MyV(IVMRWindowlessControl) * pVMRControl;
extern IBDA_SignalStatistics * pStats;
extern IBDA_DeviceControl * pBDAControl;
From pouchintv-dev at baysse.fr Sun Nov 9 23:21:51 2008
From: pouchintv-dev at baysse.fr (=?iso-8859-1?q?Liste_utilis=E9e_par_les_d=E9veloppeurs?=)
Date: Sun, 9 Nov 2008 23:21:51 +0100 (CET)
Subject: [Pouchintv-dev] [PouchinTVMod] gingko | r138 - trunk
Message-ID: <20081109222151.CA1CD6EEF3@mail.baysse.fr>
Author: gingko
Date: 2008-11-09 23:21:51 +0100 (dim, 09 nov 2008)
New Revision: 138
Modified:
trunk/epgfilter.cpp
trunk/epgfilter.h
trunk/graph.cpp
trunk/network.cpp
trunk/network.h
trunk/pmtfilter.cpp
trunk/pmtfilter.h
Log:
Normalisation des classes CNetworkProvider, CPMTFilter et CEPGFilter :
attribution de vrais CLSID (générés avec "guidgen.exe") à la place des CLSID
non conformes précédemment utilisés, définition d'interfaces de création
identiques (en vue d'un usage éventuel dans CFactoryTemplate).
Utilisation de noms de filtres plus proches des noms réels de ces filtres.
Modifié: trunk/epgfilter.cpp
===================================================================
--- trunk/epgfilter.cpp 2008-11-09 19:48:50 UTC (rev 137)
+++ trunk/epgfilter.cpp 2008-11-09 22:21:51 UTC (rev 138)
@@ -33,15 +33,15 @@
#include "crc32.h"
#include "mpeg2defs.h"
-CEPGFilter::CEPGFilter(REFCLSID clsid, HRESULT *phr) : CBaseRenderer(clsid, L"filtre EPG", NULL, phr)
+CEPGFilter::CEPGFilter(IUnknown *pUnk, HRESULT *phr) :
+ CBaseRenderer(__uuidof(this), szFilterName, pUnk, phr)
{
- myprintf(L"EPG filter construit\n");
+ myprintf(L"%s construit\n", szFilterName);
}
-
CEPGFilter::~CEPGFilter()
{
- myprintf(L"EPG filter detruit\n");
+ myprintf(L"%s detruit\n", szFilterName);
}
// Nettoyage des codes spéciaux (codes 0x80 à 0x9f) dans la chaîne,
@@ -70,6 +70,22 @@
*dst = 0;
}
+LPCTSTR CEPGFilter::szFilterName = TEXT("Filtre EPG PTvM");
+
+CUnknown * WINAPI CEPGFilter::CreateInstance(IUnknown *pUnk, HRESULT *phr) // static
+{
+ CEPGFilter *pNewFilter = new CEPGFilter(pUnk, phr);
+
+ if (phr) {
+ if (pNewFilter == NULL)
+ *phr = E_OUTOFMEMORY;
+ else
+ *phr = S_OK;
+ }
+
+ return pNewFilter;
+}
+
static void parse_eit(const SI_EIT & eit, size_t size)
{
bool modif = false;
Modifié: trunk/epgfilter.h
===================================================================
--- trunk/epgfilter.h 2008-11-09 19:48:50 UTC (rev 137)
+++ trunk/epgfilter.h 2008-11-09 22:21:51 UTC (rev 138)
@@ -29,16 +29,17 @@
#include
+[uuid("3A81A9CF-606B-458f-8244-9DC73128C79E")]
class CEPGFilter : public CBaseRenderer
{
-
public:
- CEPGFilter(REFCLSID clsid, HRESULT *phr);
+ CEPGFilter(IUnknown *pUnk, HRESULT *phr);
~CEPGFilter();
// Derived classes MUST override these
HRESULT DoRenderSample(IMediaSample *pMediaSample);
HRESULT CheckMediaType(const CMediaType *pmt);
+ static LPCTSTR szFilterName;
+ static CUnknown * WINAPI CreateInstance(IUnknown *pUnk, HRESULT *phr);
};
-
Modifié: trunk/graph.cpp
===================================================================
--- trunk/graph.cpp 2008-11-09 19:48:50 UTC (rev 137)
+++ trunk/graph.cpp 2008-11-09 22:21:51 UTC (rev 138)
@@ -351,7 +351,7 @@
if (SUCCEEDED(hr)) {
myprintf(L"Ajout video MPEG2\n");
- hr = pGraph->AddFilter(pVideoCodec, L"Codec vidéo");
+ hr = pGraph->AddFilter(pVideoCodec, filtreMPEG2);
if (FAILED(hr)) {
erreur(L"Le codec vidéo MPEG2 \"%s\" n'a pas pu être inséré dans le graphe", hr, filtreMPEG2);
return hr;
@@ -429,10 +429,10 @@
MyV(IVMRSurfaceAllocator) * pSurfAlloc = NULL;
- hr = CoCreateInstance(CLSID_AllocPresenter, NULL,
- CLSCTX_INPROC_SERVER,
+ hr = CoCreateInstance( CLSID_AllocPresenter, NULL,
+ CLSCTX_INPROC_SERVER,
MyV(IID_IVMRSurfaceAllocator),
- (LPVOID*)&pSurfAlloc);
+ (LPVOID*)&pSurfAlloc);
if (FAILED(hr)) {
erreur(L"L'interface IVMRSurfaceAllocator n'a pas été trouvée", hr);
@@ -611,7 +611,7 @@
}
// add direct sound
- hr = create_and_add_filter(CLSID_DSoundRender, L"Direct sound", pDSound);
+ hr = create_and_add_filter(CLSID_DSoundRender, L"DirectSound (MPEG2)", pDSound);
if (FAILED(hr))
return hr;
@@ -621,7 +621,7 @@
myprintf(L"ajout audio\n");
- hr = pGraph->AddFilter(pAudioCodec, L"Codec audio");
+ hr = pGraph->AddFilter(pAudioCodec, filtreAudio);
if (FAILED(hr)) {
erreur(L"Le codec audio MPEG2 \"%s\" n'a pas pu être inséré dans le graphe", hr, filtreAudio);
@@ -696,7 +696,7 @@
}
// add direct sound
- hr = create_and_add_filter(CLSID_DSoundRender, L"Direct sound le retour", pDSoundAc3);
+ hr = create_and_add_filter(CLSID_DSoundRender, L"DirectSound (AC3)", pDSoundAc3);
if (FAILED(hr))
return hr;
@@ -706,7 +706,7 @@
myprintf(L"ajout ac3\n");
- hr = pGraph->AddFilter(pAc3Codec, L"Codec ac3");
+ hr = pGraph->AddFilter(pAc3Codec, filtreAc3);
if (FAILED(hr)) {
erreur(L"Le codec audio AC3 \"%s\" n'a pas pu être inséré dans le graphe", hr, filtreAc3);
@@ -774,7 +774,7 @@
{
IBaseFilter * pMpeg2Filter = NULL;
- hr = create_and_add_filter(__uuidof(Mpeg2Data), L"MPEG2 data", pMpeg2Filter);
+ hr = create_and_add_filter(__uuidof(Mpeg2Data), L"MPEG-2 Sections and Tables", pMpeg2Filter);
if (FAILED(hr))
return hr;
@@ -791,8 +791,8 @@
hr = cherche_pin(pMpeg2Filter, PINDIR_INPUT, pPinEntree);
if (SUCCEEDED(hr) && pPinEntree!=NULL) {
- hr = pGraph->ConnectDirect(pDataPin, pPinEntree, NULL);
- pPinEntree->Release();
+ hr = pGraph->ConnectDirect(pDataPin, pPinEntree, NULL);
+ pPinEntree->Release();
}
if (FAILED(hr)) {
@@ -832,14 +832,14 @@
// add mpeg2
{
- CLSID clsid = {5, 6, 7, 8, 9, 10, 11, 12, 13};
- CEPGFilter * pEPGFilter = new CEPGFilter(clsid, &hr);
+ CEPGFilter * pEPGFilter =
+ dynamic_cast (CEPGFilter::CreateInstance(NULL, &hr));
if (FAILED(hr)) {
erreur(L"Le filtre EPG n'a pas pu être créé", hr);
return hr;
}
- hr = pGraph->AddFilter(pEPGFilter, L"Mon filtre EPG");
+ hr = pGraph->AddFilter(pEPGFilter, CEPGFilter::szFilterName);
if (FAILED(hr)) {
erreur(L"Le filtre EPG n'a pas pu être ajouté au graphe", hr);
return hr;
@@ -899,15 +899,16 @@
// add mpeg2
{
- CLSID clsid = {6, 7, 8, 9, 10, 11, 12, 13, 14};
- CPMTFilter * pPMTFilter = new CPMTFilter(clsid, &hr);
+ // CLSID clsid = {6, 7, 8, 9, 10, 11, 12, 13, 14};
+ CPMTFilter * pPMTFilter =
+ dynamic_cast(CPMTFilter::CreateInstance(NULL, &hr)); // new CPMTFilter(clsid, &hr);
- if (FAILED(hr) || pPMTFilter == NULL) {
+ if (FAILED(hr)) {
erreur(L"Le filtre PMT n'a pas pu être créé", hr);
return hr;
}
- hr = pGraph->AddFilter(pPMTFilter, L"Mon filtre PMT");
+ hr = pGraph->AddFilter(pPMTFilter, CPMTFilter::szFilterName);
if (FAILED(hr)) {
erreur(L"Le filtre PMT n'a pas pu être ajouté au graphe", hr);
return hr;
@@ -1022,13 +1023,13 @@
{
// filtre dvb-t
- CLSID clsid = {1,2,3,4,5,6,7,8,9,10,11};
- IBaseFilter * pNetworkProvider = new CNetworkProvider(clsid);
-
- if (pNetworkProvider)
- hr = pGraph->AddFilter(pNetworkProvider, L"Fake");
+ IBaseFilter * pNetworkProvider =
+ dynamic_cast(CNetworkProvider::CreateInstance(NULL, &hr));
+
+ if (SUCCEEDED(hr))
+ hr = pGraph->AddFilter(pNetworkProvider, CNetworkProvider::szFilterName);
if (FAILED(hr)) {
- erreur(L"Échec de l'insertion du filtre \"CNetworkProvider\"", hr);
+ erreur(L"Échec de l'insertion du filtre Network Provider", hr);
return hr;
}
@@ -1040,13 +1041,13 @@
// PCI
- hr = pGraph->AddFilter(pNetworkTuner, L"Network Tuner");
+ hr = pGraph->AddFilter(pNetworkTuner, nom_tuner);
if (FAILED(hr)) {
erreur(L"Échec de l'insertion du filtre Tuner", hr);
return hr;
}
- hr = pGraph->AddFilter(pReceiverComponent, L"Receiver Component");
+ hr = pGraph->AddFilter(pReceiverComponent, nom_receiver);
if (FAILED(hr)) {
erreur(L"Échec de l'insertion du filtre Récepteur", hr);
return hr;
@@ -1074,7 +1075,7 @@
// USB
// connect USB
- hr = pGraph->AddFilter(pNetworkTuner, L"Tuner USB");
+ hr = pGraph->AddFilter(pNetworkTuner, nom_tuner);
if (FAILED(hr)) {
erreur(L"Échec de l'insertion du filtre Tuner USB", hr);
return hr;
@@ -1135,7 +1136,7 @@
// connect 4
- hr = create_and_add_filter(CLSID_MPEG2Demultiplexer, L"Demux", pDemux);
+ hr = create_and_add_filter(CLSID_MPEG2Demultiplexer, L"MPEG2 Demultiplexer", pDemux);
if (FAILED(hr))
return hr;
Modifié: trunk/network.cpp
===================================================================
--- trunk/network.cpp 2008-11-09 19:48:50 UTC (rev 137)
+++ trunk/network.cpp 2008-11-09 22:21:51 UTC (rev 138)
@@ -36,16 +36,14 @@
}
-HRESULT
-CPinBidon::CheckMediaType(const CMediaType *pmt)
+HRESULT CPinBidon::CheckMediaType(const CMediaType *pmt)
{
// myprintf(L"CheckMediaType\n");
if ( *pmt->Type() == KSDATAFORMAT_TYPE_BDA_ANTENNA) return S_OK;
return S_FALSE;
}
-HRESULT
-CPinBidon::GetMediaType(int iPosition, CMediaType *pMediaType)
+HRESULT CPinBidon::GetMediaType(int iPosition, CMediaType *pMediaType)
{
myprintf(L"GetMediaType %i\n", iPosition);
if (iPosition == 0) {
@@ -60,35 +58,56 @@
}
-HRESULT
-CPinBidon::FillBuffer(IMediaSample *pSamp) {
+HRESULT CPinBidon::FillBuffer(IMediaSample *pSamp) {
//myprintf(L"CPinBidon FillBuffer\n");
return S_OK;
}
-HRESULT
-CPinBidon::DecideBufferSize(IMemAllocator * pAlloc,ALLOCATOR_PROPERTIES * ppropInputRequest)
+HRESULT CPinBidon::DecideBufferSize(IMemAllocator * pAlloc,ALLOCATOR_PROPERTIES * ppropInputRequest)
{
//myprintf(L"CPinBidon DecideBufferSize\n");
return S_OK;
}
-CNetworkProvider::CNetworkProvider(CLSID clsid) :
- CSource(L"Mon network provider", NULL, clsid)
+CNetworkProvider::CNetworkProvider(IUnknown *pUnk, HRESULT *phr) :
+ CSource(szFilterName, NULL, __uuidof(this))
{
HRESULT hr;
m_bidon = new CPinBidon(&hr, this);
- myprintf(L"network construit\n");
+ if (phr) {
+ if (m_bidon == NULL)
+ *phr = E_OUTOFMEMORY;
+ else {
+ *phr = S_OK;
+ myprintf(TEXT("%s construit\n"), szFilterName);
+ }
+ }
}
CNetworkProvider::~CNetworkProvider()
{
- myprintf(L"network detruit\n");
+ myprintf(TEXT("%s detruit\n"), szFilterName);
delete m_bidon;
}
+LPCTSTR CNetworkProvider::szFilterName = TEXT("Network Provider PTvM");
+
+CUnknown * WINAPI CNetworkProvider::CreateInstance(IUnknown *pUnk, HRESULT *phr) // static
+{
+ CNetworkProvider *pNewFilter = new CNetworkProvider(pUnk, phr);
+
+ if (phr) {
+ if (pNewFilter == NULL)
+ *phr = E_OUTOFMEMORY;
+ else
+ *phr = S_OK;
+ }
+
+ return pNewFilter;
+}
+
//
// GetPinCount
//
Modifié: trunk/network.h
===================================================================
--- trunk/network.h 2008-11-09 19:48:50 UTC (rev 137)
+++ trunk/network.h 2008-11-09 22:21:51 UTC (rev 138)
@@ -46,16 +46,19 @@
};
+[uuid("1436DC04-A20F-46a7-B9FA-CF3C95A1E00C")]
class CNetworkProvider : public CSource
{
private:
CPinBidon * m_bidon;
public:
- CNetworkProvider(CLSID clsid);
+ CNetworkProvider(IUnknown *pUnk, HRESULT *phr);
~CNetworkProvider();
int GetPinCount(void);
CBasePin *GetPin(int n);
+ static LPCTSTR szFilterName;
+ static CUnknown * WINAPI CreateInstance(IUnknown *pUnk, HRESULT *phr);
};
Modifié: trunk/pmtfilter.cpp
===================================================================
--- trunk/pmtfilter.cpp 2008-11-09 19:48:50 UTC (rev 137)
+++ trunk/pmtfilter.cpp 2008-11-09 22:21:51 UTC (rev 138)
@@ -36,17 +36,33 @@
#include "crc32.h"
-CPMTFilter::CPMTFilter(REFCLSID clsid, HRESULT *phr) : CBaseRenderer(clsid, L"filtre EPG", NULL, phr)
+CPMTFilter::CPMTFilter(IUnknown *pUnk, HRESULT *phr) :
+ CBaseRenderer(__uuidof(this), szFilterName, pUnk, phr)
{
- myprintf(L"PMT filter construit\n");
+ myprintf(TEXT("%s construit\n"), szFilterName);
}
-
CPMTFilter::~CPMTFilter()
{
- myprintf(L"PMT filter detruit\n");
+ myprintf(TEXT("%s detruit\n"), szFilterName);
}
+LPCTSTR CPMTFilter::szFilterName = TEXT("Filtre PMT PTvM");
+
+CUnknown * WINAPI CPMTFilter::CreateInstance(IUnknown *pUnk, HRESULT *phr) // static
+{
+ CPMTFilter *pNewFilter = new CPMTFilter(pUnk, phr);
+
+ if (phr) {
+ if (pNewFilter == NULL)
+ *phr = E_OUTOFMEMORY;
+ else
+ *phr = S_OK;
+ }
+
+ return pNewFilter;
+}
+
HRESULT CPMTFilter::DoRenderSample(IMediaSample *pMediaSample)
{
const SI_PMT * ppmt;
Modifié: trunk/pmtfilter.h
===================================================================
--- trunk/pmtfilter.h 2008-11-09 19:48:50 UTC (rev 137)
+++ trunk/pmtfilter.h 2008-11-09 22:21:51 UTC (rev 138)
@@ -29,16 +29,17 @@
#include
+[uuid("A72DA4DF-8931-4598-97C5-0AB895EEB356")]
class CPMTFilter : public CBaseRenderer
{
-
public:
- CPMTFilter(REFCLSID clsid, HRESULT *phr);
+ CPMTFilter(IUnknown *pUnk, HRESULT *phr);
~CPMTFilter();
// Derived classes MUST override these
HRESULT DoRenderSample(IMediaSample *pMediaSample);
HRESULT CheckMediaType(const CMediaType *pmt);
+ static LPCTSTR szFilterName;
+ static CUnknown * WINAPI CreateInstance(IUnknown *pUnk, HRESULT *phr);
};
-
From pouchintv-dev at baysse.fr Tue Nov 11 01:27:21 2008
From: pouchintv-dev at baysse.fr (=?iso-8859-1?q?Liste_utilis=E9e_par_les_d=E9veloppeurs?=)
Date: Tue, 11 Nov 2008 01:27:21 +0100 (CET)
Subject: [Pouchintv-dev] [PouchinTVMod] gingko | r139 - trunk
Message-ID: <20081111002721.4B5485F331@mail.baysse.fr>
Author: gingko
Date: 2008-11-11 01:27:20 +0100 (mar, 11 nov 2008)
New Revision: 139
Modified:
trunk/LCD.cpp
trunk/base.cpp
trunk/base.h
trunk/channels.cpp
trunk/graph.cpp
trunk/graph.h
trunk/ini.cpp
trunk/main.cpp
trunk/network.cpp
trunk/pmtfilter.cpp
trunk/record.cpp
trunk/record.h
trunk/recprog.cpp
trunk/search.cpp
trunk/search.h
trunk/utils.h
trunk/xml.cpp
trunk/xml.h
Log:
Réécriture des déclarations d'instances d'objets issus des filtres DirectShow,
ainsi que d'autres objets dérivés du modèle d'objets COM, de manière à utiliser
les "smart pointers" définis dans la bibliothèques de modèles de classes
(templates) ATL. Ces classes gérant automatiquement les ajouts et suppressions
de références de ces objets (AddRef et Release), ceci permet de supprimer
la plupart de ces instructions, tout en s'assurant d'une gestion optimale
de ces objets avec réduction au minimum des risques de fuites de mémoires
et d'objets non détruits.
Ajout d'un nouvel appel redondant à "CoInitializeEx" en cas d'échec de
de la création du graphe, en raison du fait que certains filtres DirectShow
(Nero...) semblent s'autoprotéger contre les usages non autorisés en exécutant
une instruction "CoUninitialize", ce qui compliquait sérieusement le retour
subséquent au dialogue de configuration.
Optimisation supplémentaire de la gestion des messages d'erreurs (via ajout d'une
recopie du code d'erreur transmis à la fonction "erreur" vers la valeur de retour
de cette fonction).
Modifié: trunk/LCD.cpp
===================================================================
--- trunk/LCD.cpp 2008-11-09 22:21:51 UTC (rev 138)
+++ trunk/LCD.cpp 2008-11-11 00:27:20 UTC (rev 139)
@@ -24,9 +24,6 @@
//
// Il faut simplement installer les pilotes du clavier logitech G15 ou des enceintes Z10
-#include
-#include
-
#include "base.h"
#include "main.h"
#include "LCD.h"
Modifié: trunk/base.cpp
===================================================================
--- trunk/base.cpp 2008-11-09 22:21:51 UTC (rev 138)
+++ trunk/base.cpp 2008-11-11 00:27:20 UTC (rev 139)
@@ -34,12 +34,12 @@
static LPWSTR pszErrBuf = NULL;
static HRESULT lastRes = S_OK;
-void erreur(LPCWSTR str, HRESULT hr, ...)
+HRESULT erreur(LPCWSTR str, HRESULT hr, ...)
{
- LPWSTR pszNewErrBuf;
WCHAR buffer[0x200];
if (str) {
+ LPWSTR pszNewErrBuf;
va_list argptr;
va_start(argptr, hr);
@@ -62,15 +62,16 @@
pszNewErrBuf = new WCHAR[nBufLen];
wcscpy_s(pszNewErrBuf, nBufLen, buffer);
}
+ pszErrBuf = pszNewErrBuf;
}
- pszErrBuf = pszNewErrBuf;
- if (hr!=S_OK && hr!=lastRes) {
+ if (FAILED(hr) && hr!=lastRes) {
AMGetErrorText(hr, buffer, _countof(buffer));
erreur(L"%s (code 0x%08x)", S_OK, buffer, hr);
lastRes = hr;
}
+ return hr;
}
void affiche_erreurs(LPCWSTR str, HRESULT hr)
Modifié: trunk/base.h
===================================================================
--- trunk/base.h 2008-11-09 22:21:51 UTC (rev 138)
+++ trunk/base.h 2008-11-11 00:27:20 UTC (rev 139)
@@ -42,6 +42,7 @@
#include
#include
+#include
#include
#include
@@ -64,6 +65,8 @@
#pragma warning(disable:4995)
#include
+#include
+
#include "resource.h"
// Décommenter si on veut afficher la console de debugging :
@@ -175,5 +178,5 @@
etf_minimized // minimisée (en icône ou pas)
};
-void erreur(LPCWSTR str, HRESULT hr, ...);
+HRESULT erreur(LPCWSTR str, HRESULT hr, ...);
void affiche_erreurs(LPCWSTR str, HRESULT hr=S_OK);
Modifié: trunk/channels.cpp
===================================================================
--- trunk/channels.cpp 2008-11-09 22:21:51 UTC (rev 138)
+++ trunk/channels.cpp 2008-11-11 00:27:20 UTC (rev 139)
@@ -253,7 +253,7 @@
// S'assurer que le VMR a été initialisé :
bool do_init_vmr()
{
- if (pVMRControl == NULL) {
+ if (!pVMRControl) {
HRESULT hr = init_vmr();
if (FAILED(hr)) {
@@ -265,17 +265,18 @@
return true;
}
-static void debranche_tout(IMPEG2PIDMap * pMap)
+static void debranche_tout(CComPtr & pMap)
{
- IEnumPIDMap * pEnumMap;
- pMap->EnumPIDMap(&pEnumMap);
-
PID_MAP maps[8];
- ULONG nbPids;
- pEnumMap->Next(8, maps, &nbPids);
+ ULONG nbPids;
- pEnumMap->Release();
+ {
+ CComPtr pEnumMap;
+ pMap->EnumPIDMap(&pEnumMap);
+ pEnumMap->Next(_countof(maps), maps, &nbPids);
+ }
+
for (ULONG i=0; iUnmapPID(1, &maps[i].ulPID);
myprintf(L"%?unmap foiré, hr=0x%08x\n", FAILED(hr), hr);
@@ -407,13 +408,8 @@
void set_volume(long volume)
{
- IBasicAudio * pBas;
+ CComQIPtr pBas(pGraph);
- HRESULT hr = pGraph->QueryInterface(&pBas);
-
- myprintf(L"%?erreur set_volume, hr=0x%08x\n", FAILED(hr), hr);
- if (SUCCEEDED(hr)) {
+ if (pBas)
pBas->put_Volume(volume);
- pBas->Release();
- }
}
Modifié: trunk/graph.cpp
===================================================================
--- trunk/graph.cpp 2008-11-09 22:21:51 UTC (rev 138)
+++ trunk/graph.cpp 2008-11-11 00:27:20 UTC (rev 139)
@@ -37,35 +37,35 @@
#include
-IFilterGraph2 * pGraph = NULL;
-IMediaControl * pControl = NULL;
+CComPtr pGraph;
+CComPtr pControl;
-MyV(IVMRWindowlessControl) * pVMRControl = NULL;
+CComPtr pVMRControl;
-IBaseFilter * pDemux = NULL;
+CComPtr pDemux;
-IBaseFilter * pVideoCodec = NULL;
-IBaseFilter * pAudioCodec = NULL;
-IBaseFilter * pAc3Codec = NULL;
+CComPtr pVideoCodec;
+CComPtr pAudioCodec;
+CComPtr pAc3Codec;
-IBaseFilter * pVMR = NULL;
-IBaseFilter * pDSound = NULL;
-IBaseFilter * pDSoundAc3 = NULL;
+CComPtr pVMR;
+CComPtr pDSound;
+CComPtr pDSoundAc3;
-IMPEG2PIDMap * pMapMPEG2 = NULL;
-IMPEG2PIDMap * pMapH264 = NULL;
-IMPEG2PIDMap * pMapSound = NULL;
-IMPEG2PIDMap * pMapAc3 = NULL;
-IMPEG2PIDMap * pMapPmt = NULL;
+CComPtr pMapMPEG2;
+CComPtr pMapH264;
+CComPtr pMapSound;
+CComPtr pMapAc3;
+CComPtr pMapPmt;
-IMpeg2Data * pMpeg2Data = NULL;
+CComPtr pMpeg2Data;
-IBaseFilter * pNetworkTuner = NULL;
-IBaseFilter * pReceiverComponent = NULL;
+CComPtr pNetworkTuner;
+CComPtr pReceiverComponent;
-IBDA_DeviceControl * pBDAControl;
-IBDA_FrequencyFilter * pBDAFreq;
-IBDA_SignalStatistics * pStats;
+CComPtr pBDAControl;
+CComPtr pBDAFreq;
+CComPtr pStats;
bool use_vmr_deinterlace = false;
@@ -75,32 +75,30 @@
static HRESULT AddToRot()
{
- IMoniker * pMoniker = NULL;
- IRunningObjectTable *pROT = NULL;
+ CComPtr pMoniker;
+ CComPtr pROT;
+ WCHAR wsz[256];
- if (FAILED(GetRunningObjectTable(0, &pROT))) {
+ if (FAILED(GetRunningObjectTable(0, &pROT)))
return E_FAIL;
- }
- WCHAR wsz[256];
- StringCchPrintfW(wsz, _countof(wsz), L"FilterGraph %08x pid %08x", (DWORD_PTR)pGraph, GetCurrentProcessId());
+ StringCchPrintfW(wsz, _countof(wsz), L"FilterGraph %08x pid %08x", (DWORD_PTR)&pGraph.p, GetCurrentProcessId());
+
HRESULT hr = CreateItemMoniker(L"!", wsz, &pMoniker);
- if (SUCCEEDED(hr)) {
+
+ if (SUCCEEDED(hr))
hr = pROT->Register(ROTFLAGS_REGISTRATIONKEEPSALIVE, pGraph,
- pMoniker, &pdwRegister);
- pMoniker->Release();
- }
- pROT->Release();
+ pMoniker, &pdwRegister);
+
return hr;
}
static void RemoveFromRot()
{
- IRunningObjectTable *pROT;
- if (SUCCEEDED(GetRunningObjectTable(0, &pROT))) {
+ CComPtr pROT;
+
+ if (SUCCEEDED(GetRunningObjectTable(0, &pROT)))
pROT->Revoke(pdwRegister);
- pROT->Release();
- }
}
#endif // #if EXPORT_GRAPH
@@ -133,182 +131,179 @@
RemoveFromRot();
#endif // #if EXPORT_GRAPH
- free_interface(pMpeg2Data);
+ pMpeg2Data.Release();
- free_interface(pVMRControl);
- free_interface(pGraph);
+ pVMRControl.Release();
+ pGraph.Release();
- free_interface(pVideoCodec);
- free_interface(pAudioCodec);
- free_interface(pAc3Codec);
+ pVideoCodec.Release();
+ pAudioCodec.Release();
+ pAc3Codec.Release();
- free_interface(pMapMPEG2);
- free_interface(pMapH264);
- free_interface(pMapSound);
- free_interface(pMapAc3);
- free_interface(pMapPmt);
+ pMapMPEG2.Release();
+ pMapH264.Release();
+ pMapSound.Release();
+ pMapAc3.Release();
+ pMapPmt.Release();
- free_interface(pDemux);
- free_interface(pVMR);
- free_interface(pDSound);
- free_interface(pDSoundAc3);
+ pDemux.Release();
+ pVMR.Release();
+ pDSound.Release();
+ pDSoundAc3.Release();
- free_interface(pNetworkTuner);
- free_interface(pReceiverComponent);
+ pNetworkTuner.Release();
+ pReceiverComponent.Release();
- free_interface(pStats);
- free_interface(pBDAFreq);
- free_interface(pBDAControl);
+ pStats.Release();
+ pBDAFreq.Release();
+ pBDAControl.Release();
// Libère les interfaces d'enregistrements
for (int i=0; i & pFilter)
{
- HRESULT hr = CoCreateInstance(clsid, NULL, CLSCTX_INPROC_SERVER,
- IID_IBaseFilter, (void**)&pFilter);
+ HRESULT hr = pFilter.CoCreateInstance(clsid, NULL, CLSCTX_INPROC_SERVER);
- if (FAILED(hr)) {
- erreur(L"Le filtre \"%s\" n'a pas pu être créé", hr, nom);
- return hr;
- }
+ if (FAILED(hr))
+ return erreur(L"Le filtre \"%s\" n'a pas pu être créé", hr, nom);
hr = pGraph->AddFilter(pFilter, nom);
- if (FAILED(hr)) {
- pFilter->Release();
- erreur(L"Le filtre \"%s\" n'a pas pu être ajouté au graphe", hr, nom);
- }
+ if (FAILED(hr))
+ return erreur(L"Le filtre \"%s\" n'a pas pu être ajouté au graphe", hr, nom);
return hr;
}
-static HRESULT connect_filters(IBaseFilter * source, IBaseFilter * dest)
+static HRESULT connect_filters(CComPtr & source, CComPtr & dest)
{
- IPin * pPin1 = NULL;
- IPin * pPin2 = NULL;
- HRESULT hr = cherche_pin(source, PINDIR_OUTPUT, pPin1);
+ CComPtr pPin1;
+ CComPtr pPin2;
+ HRESULT hr = cherche_pin(source, PINDIR_OUTPUT, pPin1);
- if (SUCCEEDED(hr) && pPin1!=NULL) {
+ if (SUCCEEDED(hr)) {
hr = cherche_pin(dest, PINDIR_INPUT, pPin2);
- if (SUCCEEDED(hr) && pPin2!=NULL) {
+ if (SUCCEEDED(hr))
hr = pGraph->ConnectDirect(pPin1, pPin2, NULL);
- pPin2->Release();
- }
- pPin1->Release();
}
return hr;
}
-static HRESULT getFrequencyFilter(IBaseFilter * pNetworkTuner)
+static HRESULT getFrequencyFilter(CComPtr & pNetworkTuner)
{
- HRESULT hr = pNetworkTuner->QueryInterface(&pBDAControl);
- if (FAILED(hr)) {
- erreur(L"L'interface IBDA_DeviceControl n'a pas été trouvée", hr);
- return hr;
- }
+ HRESULT hr = pNetworkTuner.QueryInterface(&pBDAControl);
- IBDA_Topology * pTop;
- hr = pNetworkTuner->QueryInterface(&pTop);
- if (FAILED(hr)) {
- erreur(L"L'interface IBDA_Topology n'a pas été trouvée", hr);
- return hr;
- }
+ if (FAILED(hr))
+ return erreur(L"L'interface IBDA_DeviceControl n'a pas été trouvée", hr);
+ CComQIPtr pTop(pNetworkTuner);
+
+ if (!pTop)
+ return erreur(L"L'interface IBDA_Topology n'a pas été trouvée", E_NOINTERFACE);
+
ULONG NodeTypes;
ULONG NodeType[32];
- hr = pTop->GetNodeTypes(&NodeTypes, 32, NodeType);
+ hr = pTop->GetNodeTypes(&NodeTypes, _countof(NodeType), NodeType);
- if (hr == S_OK) {
- for (ULONG i = 0; i < NodeTypes && pBDAFreq == NULL; i++) {
- ULONG Interfaces;
- GUID Interface[32];
+ if (FAILED(hr))
+ return hr;
- hr = pTop->GetNodeInterfaces(NodeType[i], &Interfaces, 32, Interface);
+ for (ULONG i = 0; i < NodeTypes && !pBDAFreq; i++) {
+ ULONG Interfaces;
+ GUID Interface[32];
- if (hr == S_OK) {
+ hr = pTop->GetNodeInterfaces(NodeType[i], &Interfaces, _countof(Interface), Interface);
- bool found = false;
+ if (FAILED(hr))
+ continue;
- for (ULONG j = 0; j < Interfaces; j++) {
- if (Interface[j] == IID_IBDA_FrequencyFilter) {
- found = true;
- }
- }
+ bool found = false;
- if (found) {
- IUnknown * pUnk;
- hr = pTop->GetControlNode(0, 1, NodeType[i], &pUnk);
- if (SUCCEEDED(hr)) {
- hr = pUnk->QueryInterface(&pBDAFreq);
- pUnk->Release();
- }
- }
+ for (ULONG j = 0; j < Interfaces; j++) {
+ if (Interface[j] == IID_IBDA_FrequencyFilter) {
+ found = true;
+ break;
}
}
+
+ if (found) {
+ CComPtr pUnk;
+
+ hr = pTop->GetControlNode(0, 1, NodeType[i], &pUnk);
+ if (SUCCEEDED(hr)) {
+ hr = pUnk.QueryInterface(&pBDAFreq);
+ break;
+ }
+ }
}
- pTop->Release();
- return hr;
+ return !pBDAFreq ? E_NOINTERFACE : hr;
}
-static HRESULT getSignalStatistics(IBaseFilter * pNetworkTuner)
+static HRESULT getSignalStatistics(CComPtr & pNetworkTuner)
{
+ CComQIPtr pTop(pNetworkTuner);
- IBDA_Topology * pTop;
- HRESULT hr = pNetworkTuner->QueryInterface(&pTop);
- if (FAILED(hr)) {
- erreur(L"L'interface IBDA_Topology n'a pas été trouvée", hr);
- return hr;
- }
+ if (!pTop)
+ return erreur(L"L'interface IBDA_Topology n'a pas été trouvée", E_NOINTERFACE);
ULONG NodeTypes;
ULONG NodeType[32];
- hr = pTop->GetNodeTypes(&NodeTypes, 32, NodeType);
+ HRESULT hr = pTop->GetNodeTypes(&NodeTypes, _countof(NodeType), NodeType);
- if (hr == S_OK) {
- for (ULONG i = 0; i < NodeTypes && pStats == NULL; i++) {
- ULONG Interfaces;
- GUID Interface[32];
+ if (FAILED(hr))
+ return hr;
- hr = pTop->GetNodeInterfaces(NodeType[i], &Interfaces, 32, Interface);
+ for (ULONG i = 0; i < NodeTypes && !pStats; i++) {
+ ULONG Interfaces;
+ GUID Interface[32];
- if (hr == S_OK) {
- bool found = false;
+ hr = pTop->GetNodeInterfaces(NodeType[i], &Interfaces, _countof(Interface), Interface);
- for (ULONG j = 0; j < Interfaces; j++) {
- if (Interface[j] == IID_IBDA_SignalStatistics ) {
- found = true;
- }
- }
+ if (FAILED(hr))
+ continue;
- if (found) {
- IUnknown * pUnk;
- hr = pTop->GetControlNode(0, 1, NodeType[i], &pUnk);
- if (SUCCEEDED(hr)) {
- hr = pUnk->QueryInterface(&pStats);
- pUnk->Release();
- }
- }
+ bool found = false;
+
+ for (ULONG j = 0; j < Interfaces; j++) {
+ if (Interface[j] == IID_IBDA_SignalStatistics) {
+ found = true;
+ break;
}
}
+
+ if (found) {
+ CComPtr pUnk;
+
+ hr = pTop->GetControlNode(0, 1, NodeType[i], &pUnk);
+ if (SUCCEEDED(hr)) {
+ hr = pUnk.QueryInterface(&pStats);
+ break;
+ }
+ }
}
- pTop->Release();
- return hr;
+ return !pStats ? E_NOINTERFACE : hr;
}
static HRESULT render_mp2v(IMpeg2Demultiplexer * pMpeg2Demux)
{
- IPin * pVideoPin;
+ if (filtreMPEG2[0] == 0) {
+ affiche_erreurs(L"Aucun codec vidéo MPEG2 n'a été sélectionné");
+ return S_OK;
+ }
+ CComPtr pVideoPin;
+
AM_MEDIA_TYPE am;
am.majortype = MEDIATYPE_Video;
am.subtype = MEDIASUBTYPE_MPEG2_VIDEO;
@@ -341,10 +336,8 @@
mvi.hdr.bmiHeader.biHeight = 576;
HRESULT hr = pMpeg2Demux->CreateOutputPin(&am, L"video", &pVideoPin);
- if (FAILED(hr)) {
- erreur(L"La broche vidéo MPEG2 n'a pas pu être créée", hr);
- return hr;
- }
+ if (FAILED(hr))
+ return erreur(L"La broche vidéo MPEG2 n'a pas pu être créée", hr);
// le décodeur vidéo
hr = get_filter(MEDIATYPE_Video, MEDIASUBTYPE_MPEG2_VIDEO, filtreMPEG2, pVideoCodec);
@@ -352,33 +345,24 @@
myprintf(L"Ajout video MPEG2\n");
hr = pGraph->AddFilter(pVideoCodec, filtreMPEG2);
- if (FAILED(hr)) {
- erreur(L"Le codec vidéo MPEG2 \"%s\" n'a pas pu être inséré dans le graphe", hr, filtreMPEG2);
- return hr;
- }
+ if (FAILED(hr))
+ return erreur(L"Le codec vidéo MPEG2 \"%s\" n'a pas pu être inséré dans le graphe", hr, filtreMPEG2);
- IPin * pPinEntree = NULL;
+ CComPtr pPinEntree;
hr = cherche_pin(pVideoCodec, PINDIR_INPUT, pPinEntree);
- if (SUCCEEDED(hr) && pPinEntree!=NULL) {
+ if (SUCCEEDED(hr))
hr = pGraph->ConnectDirect(pVideoPin, pPinEntree, NULL);
- pPinEntree->Release();
- }
- if (FAILED(hr)) {
- erreur(L"Impossible de connecter le démultiplexeur au codec vidéo MPEG2 \"%s\"", hr, filtreMPEG2);
- return hr;
- }
+ if (FAILED(hr))
+ return erreur(L"Impossible de connecter le démultiplexeur au codec vidéo MPEG2 \"%s\"", hr, filtreMPEG2);
} else {
hr = pGraph->RenderEx(pVideoPin, AM_RENDEREX_RENDERTOEXISTINGRENDERERS, NULL);
- if (FAILED(hr)) {
- erreur(L"Pas de rendu possible depuis la broche vidéo MPEG2", hr);
- return hr;
- }
+ if (FAILED(hr))
+ return erreur(L"Pas de rendu possible depuis la broche vidéo MPEG2", hr);
}
- pVideoPin->QueryInterface(&pMapMPEG2);
- pVideoPin->Release();
+ pVideoPin.QueryInterface(&pMapMPEG2);
return hr;
}
@@ -397,13 +381,11 @@
return hr;
{
- MyV(IVMRFilterConfig) * pVMRConfig;
- hr = pVMR->QueryInterface(&pVMRConfig);
- if (FAILED(hr)) {
- erreur(L"L'interface de configuration VMR n'est pas disponible", hr);
- return hr;
- }
+ CComQIPtr pVMRConfig(pVMR);
+ if (!pVMRConfig)
+ return erreur(L"L'interface de configuration VMR n'est pas disponible", E_NOINTERFACE);
+
#if USE_VMR9
hr = pVMRConfig->SetRenderingMode(MyVMRMode_Windowless);
#else
@@ -412,80 +394,62 @@
if (SUCCEEDED(hr) && use_vmr_deinterlace)
hr = pVMRConfig->SetNumberOfStreams(1);
#endif
-
- pVMRConfig->Release();
- if (FAILED(hr))
- return hr;
}
+ if (FAILED(hr))
+ return hr;
+
#if !USE_VMR9 // Modif R_One - à revérifier
{
- MyV(IVMRSurfaceAllocatorNotify) * pNotify;
- hr = pVMR->QueryInterface(&pNotify);
- if (FAILED(hr)) {
- erreur(L"L'interface IVMRSurfaceAllocatorNotify n'a pas été trouvée", hr);
- return hr;
- }
+ CComQIPtr pNotify(pVMR);
- MyV(IVMRSurfaceAllocator) * pSurfAlloc = NULL;
+ if (!pNotify)
+ return erreur(L"L'interface IVMRSurfaceAllocatorNotify n'a pas été trouvée", E_NOINTERFACE);
- hr = CoCreateInstance( CLSID_AllocPresenter, NULL,
- CLSCTX_INPROC_SERVER,
- MyV(IID_IVMRSurfaceAllocator),
- (LPVOID*)&pSurfAlloc);
+ CComPtr pSurfAlloc;
- if (FAILED(hr)) {
- erreur(L"L'interface IVMRSurfaceAllocator n'a pas été trouvée", hr);
- return hr;
- }
+ hr = pSurfAlloc.CoCreateInstance(CLSID_AllocPresenter, NULL, CLSCTX_INPROC_SERVER);
- MyV(IVMRImagePresenterConfig) * pPresConf = NULL;
+ if (FAILED(hr))
+ return erreur(L"L'interface IVMRSurfaceAllocator n'a pas été trouvée", hr);
- hr = pSurfAlloc->QueryInterface(&pPresConf);
- if (FAILED(hr)) {
- erreur(L"L'interface IVMRImagePresenterConfig n'a pas été trouvée", hr);
- return hr;
- }
+ {
+ CComQIPtr pPresConf(pSurfAlloc);
- if (is_vista) {
- hr = pPresConf->SetRenderingPrefs(RenderPrefs_AllowOffscreen);
- } else {
- hr = pPresConf->SetRenderingPrefs(RenderPrefs_ForceOverlays | RenderPrefs_DoNotRenderColorKeyAndBorder);
+ if (!pPresConf)
+ return erreur(L"L'interface IVMRImagePresenterConfig n'a pas été trouvée", E_NOINTERFACE);
+
+ hr = pPresConf->SetRenderingPrefs(
+ is_vista ?
+ RenderPrefs_AllowOffscreen :
+ (RenderPrefs_ForceOverlays | RenderPrefs_DoNotRenderColorKeyAndBorder)
+ );
+
+ if (FAILED(hr))
+ return erreur(L"Échec de SetRenderingPrefs", hr);
}
- pPresConf->Release();
- if (FAILED(hr)) {
- erreur(L"Échec de SetRenderingPrefs", hr);
- return hr;
- }
pNotify->AdviseSurfaceAllocator(0x118218, pSurfAlloc);
pSurfAlloc->AdviseNotify(pNotify);
}
if (use_vmr_deinterlace) {
+ {
+ CComQIPtr pMixControl(pVMR);
- MyV(IVMRMixerControl) * pMixControl;
-
- hr = pVMR->QueryInterface(&pMixControl);
- if (FAILED(hr)) {
- erreur(L"L'interface IVMRMixerControl n'a pas été trouvée", hr);
- return hr;
+ if (!pMixControl)
+ return erreur(L"L'interface IVMRMixerControl n'a pas été trouvée", E_NOINTERFACE);
+ hr = pMixControl->SetMixingPrefs(MyMIXINGPREFS);
}
- hr = pMixControl->SetMixingPrefs(MyMIXINGPREFS);
- pMixControl->Release();
- if (FAILED(hr)) {
- erreur(L"Échec de SetMixingPrefs", hr);
- return hr;
- }
+ if (FAILED(hr))
+ return erreur(L"Échec de SetMixingPrefs", hr);
- MyV(IVMRDeinterlaceControl) * pDeint;
- hr = pVMR->QueryInterface(&pDeint);
- if (FAILED(hr)) {
- erreur(L"L'interface IVMRDeinterlaceControl n'a pas été trouvée", hr);
- return hr;
- }
+ CComQIPtr pDeint(pVMR);
+ if (!pDeint)
+ return erreur(L"L'interface IVMRDeinterlaceControl n'a pas été trouvée", E_NOINTERFACE);
+
DWORD num;
MyVMRVideoDesc desc;
@@ -507,10 +471,8 @@
hr = pDeint->GetNumberOfDeinterlaceModes(&desc, &num, NULL);
- if (FAILED(hr)) {
- erreur(L"Nombre de modes de désentrelacement non trouvé", hr);
- return hr;
- }
+ if (FAILED(hr))
+ return erreur(L"Nombre de modes de désentrelacement non trouvé", hr);
myprintf(L"num : %i\n", num);
@@ -519,23 +481,18 @@
hr = pDeint->GetNumberOfDeinterlaceModes(&desc, &num, guid);
- if (FAILED(hr)) {
- erreur(L"Impossible d'avoir le GUID du désentrelacement", hr);
- return hr;
- }
+ if (FAILED(hr))
+ return erreur(L"Impossible d'avoir le GUID du désentrelacement", hr);
hr = pDeint->SetDeinterlaceMode(0xFFFFFFFF, &guid[0]);
- pDeint->Release();
- if (FAILED(hr)) {
- erreur(L"Impossible de mettre le mode de désentrelacement", hr);
- return hr;
- }
+ if (FAILED(hr))
+ return erreur(L"Impossible de mettre le mode de désentrelacement", hr);
}
#endif // #if !USE_VMR9
- hr = pVMR->QueryInterface(&pVMRControl);
+ hr = pVMR.QueryInterface(&pVMRControl);
if (FAILED(hr)) {
erreur(L"L'interface de contrôle VMR n'est pas disponible", hr);
return hr;
@@ -548,16 +505,11 @@
#endif
{
- MyV(IVMRAspectRatioControl) * pARC;
- hr = pVMR->QueryInterface(&pARC);
+ CComQIPtr pARC(pVMR);
- if (FAILED(hr)) {
- erreur(L"L'interface de contrôle du ratio d'aspect n'est pas disponible", hr);
- return hr;
- }
-
+ if (!pARC)
+ return erreur(L"L'interface de contrôle du ratio d'aspect n'est pas disponible", E_NOINTERFACE);
pARC->SetAspectRatioMode(VMR_ARMODE_LETTER_BOX);
- pARC->Release();
}
@@ -580,7 +532,7 @@
static HRESULT render_son(IMpeg2Demultiplexer * pMpeg2Demux)
{
- IPin * pSoundPin;
+ CComPtr pSoundPin;
AM_MEDIA_TYPE am;
am.majortype = MEDIATYPE_Audio;
@@ -605,10 +557,8 @@
wfm.cbSize = 0;
HRESULT hr = pMpeg2Demux->CreateOutputPin(&am, L"son", &pSoundPin);
- if (FAILED(hr)) {
- erreur(L"La broche audio MPEG2 n'a pas pu être créée", hr);
- return hr;
- }
+ if (FAILED(hr))
+ return erreur(L"La broche audio MPEG2 n'a pas pu être créée", hr);
// add direct sound
hr = create_and_add_filter(CLSID_DSoundRender, L"DirectSound (MPEG2)", pDSound);
@@ -623,48 +573,37 @@
hr = pGraph->AddFilter(pAudioCodec, filtreAudio);
- if (FAILED(hr)) {
- erreur(L"Le codec audio MPEG2 \"%s\" n'a pas pu être inséré dans le graphe", hr, filtreAudio);
- return hr;
- }
+ if (FAILED(hr))
+ return erreur(L"Le codec audio MPEG2 \"%s\" n'a pas pu être inséré dans le graphe", hr, filtreAudio);
- IPin * pPinEntree = NULL;
+ CComPtr pPinEntree;
hr = cherche_pin(pAudioCodec, PINDIR_INPUT, pPinEntree);
- if (SUCCEEDED(hr) && pPinEntree != NULL) {
+ if (SUCCEEDED(hr))
hr = pGraph->ConnectDirect(pSoundPin, pPinEntree, NULL);
- pPinEntree->Release();
- }
- if (FAILED(hr)) {
- erreur(L"Impossible de connecter le démultiplexeur au codec audio MPEG2 \"%s\"", hr, filtreAudio);
- return hr;
- }
+ if (FAILED(hr))
+ return erreur(L"Impossible de connecter le démultiplexeur au codec audio MPEG2 \"%s\"", hr, filtreAudio);
hr = connect_filters(pAudioCodec, pDSound);
- if (FAILED(hr)) {
- erreur(L"Impossible de connecter le Codec audio MPEG2 \"%s\" au filtre de rendu DirectSound", hr, filtreAudio);
- return hr;
- }
+ if (FAILED(hr))
+ return erreur(L"Impossible de connecter le Codec audio MPEG2 \"%s\" au filtre de rendu DirectSound", hr, filtreAudio);
} else {
hr = pGraph->RenderEx(pSoundPin, AM_RENDEREX_RENDERTOEXISTINGRENDERERS, NULL);
- if (FAILED(hr)) {
- erreur(L"Pas de rendu possible depuis la broche audio MPEG2", hr);
- return hr;
- }
+ if (FAILED(hr))
+ return erreur(L"Pas de rendu possible depuis la broche audio MPEG2", hr);
}
- hr = pSoundPin->QueryInterface(&pMapSound);
+ hr = pSoundPin.QueryInterface(&pMapSound);
myprintf(L"%?erreur pMapSound, hr=0x%08x\n", FAILED(hr), hr);
- pSoundPin->Release();
return hr;
}
static HRESULT render_ac3(IMpeg2Demultiplexer * pMpeg2Demux)
{
- IPin * pAc3Pin;
+ CComPtr pAc3Pin;
AM_MEDIA_TYPE am;
am.majortype = MEDIATYPE_Audio;
@@ -690,10 +629,8 @@
HRESULT hr = pMpeg2Demux->CreateOutputPin(&am, L"ac3", &pAc3Pin);
- if (FAILED(hr)) {
- erreur(L"La broche audio AC3 n'a pas pu être créée", hr);
- return hr;
- }
+ if (FAILED(hr))
+ return erreur(L"La broche audio AC3 n'a pas pu être créée", hr);
// add direct sound
hr = create_and_add_filter(CLSID_DSoundRender, L"DirectSound (AC3)", pDSoundAc3);
@@ -708,41 +645,30 @@
hr = pGraph->AddFilter(pAc3Codec, filtreAc3);
- if (FAILED(hr)) {
- erreur(L"Le codec audio AC3 \"%s\" n'a pas pu être inséré dans le graphe", hr, filtreAc3);
- return hr;
- }
+ if (FAILED(hr))
+ return erreur(L"Le codec audio AC3 \"%s\" n'a pas pu être inséré dans le graphe", hr, filtreAc3);
- IPin * pPinEntree = NULL;
+ CComPtr pPinEntree;
hr = cherche_pin(pAc3Codec, PINDIR_INPUT, pPinEntree);
- if (SUCCEEDED(hr) && pPinEntree!=NULL) {
+ if (SUCCEEDED(hr))
hr = pGraph->ConnectDirect(pAc3Pin, pPinEntree, NULL);
- pPinEntree->Release();
- }
- if (FAILED(hr)) {
- erreur(L"Impossible de connecter le démultiplexeur au codec AC3 \"%s\"", hr, filtreAc3);
- return hr;
- }
+ if (FAILED(hr))
+ return erreur(L"Impossible de connecter le démultiplexeur au codec AC3 \"%s\"", hr, filtreAc3);
hr = connect_filters(pAc3Codec, pDSoundAc3);
- if (FAILED(hr)) {
- erreur(L"Impossible de connecter le Codec audio AC3 \"%s\" au filtre de rendu DirectSound", hr, filtreAc3);
- return hr;
- }
+ if (FAILED(hr))
+ return erreur(L"Impossible de connecter le Codec audio AC3 \"%s\" au filtre de rendu DirectSound", hr, filtreAc3);
} else {
hr = pGraph->RenderEx(pAc3Pin, AM_RENDEREX_RENDERTOEXISTINGRENDERERS, NULL);
- if (FAILED(hr)) {
- erreur(L"Pas de rendu possible depuis la broche audio AC3", hr);
- return hr;
- }
+ if (FAILED(hr))
+ return erreur(L"Pas de rendu possible depuis la broche audio AC3", hr);
}
- hr = pAc3Pin->QueryInterface(&pMapAc3);
+ hr = pAc3Pin.QueryInterface(&pMapAc3);
myprintf(L"%?erreur pMapAc3, hr=0x%08x\n", FAILED(hr), hr);
- pAc3Pin->Release();
return hr;
}
@@ -750,7 +676,7 @@
static HRESULT render_psi(IMpeg2Demultiplexer * pMpeg2Demux)
{
- IPin * pDataPin;
+ CComPtr pDataPin;
AM_MEDIA_TYPE am;
am.majortype = MEDIATYPE_MPEG2_SECTIONS;
@@ -772,45 +698,37 @@
// add mpeg2
{
- IBaseFilter * pMpeg2Filter = NULL;
+ CComPtr pPSIFilter;
- hr = create_and_add_filter(__uuidof(Mpeg2Data), L"MPEG-2 Sections and Tables", pMpeg2Filter);
+ hr = create_and_add_filter(__uuidof(Mpeg2Data), L"MPEG-2 Sections and Tables", pPSIFilter);
if (FAILED(hr))
return hr;
// query MPEG-2 Sections and Tables Filter
- hr = pMpeg2Filter->QueryInterface(&pMpeg2Data);
+ hr = pPSIFilter.QueryInterface(&pMpeg2Data);
if (FAILED(hr)) {
erreur(L"L'interface d'accès aux tables PSI n'a pas été trouvée", hr);
return hr;
}
- IPin * pPinEntree = NULL;
+ CComPtr pPinEntree;
- hr = cherche_pin(pMpeg2Filter, PINDIR_INPUT, pPinEntree);
- if (SUCCEEDED(hr) && pPinEntree!=NULL) {
+ hr = cherche_pin(pPSIFilter, PINDIR_INPUT, pPinEntree);
+ if (SUCCEEDED(hr))
hr = pGraph->ConnectDirect(pDataPin, pPinEntree, NULL);
- pPinEntree->Release();
- }
- if (FAILED(hr)) {
- erreur(L"Impossible de connecter le démultiplexeur au filtre PSI", hr);
- return hr;
- }
-
- pMpeg2Filter->Release();
+ if (FAILED(hr))
+ return erreur(L"Impossible de connecter le démultiplexeur au filtre PSI", hr);
}
- pDataPin->Release();
-
return hr;
}
static HRESULT render_epgfilter(IMpeg2Demultiplexer * pMpeg2Demux)
{
- IPin * pEpgPin;
+ CComPtr pEpgPin;
AM_MEDIA_TYPE am;
am.majortype = MEDIATYPE_MPEG2_SECTIONS;
@@ -832,52 +750,41 @@
// add mpeg2
{
- CEPGFilter * pEPGFilter =
+ CComPtr pEPGFilter =
dynamic_cast (CEPGFilter::CreateInstance(NULL, &hr));
- if (FAILED(hr)) {
- erreur(L"Le filtre EPG n'a pas pu être créé", hr);
- return hr;
- }
+ if (FAILED(hr))
+ return erreur(L"Le filtre EPG n'a pas pu être créé", hr);
hr = pGraph->AddFilter(pEPGFilter, CEPGFilter::szFilterName);
- if (FAILED(hr)) {
- erreur(L"Le filtre EPG n'a pas pu être ajouté au graphe", hr);
- return hr;
- }
+ if (FAILED(hr))
+ return erreur(L"Le filtre EPG n'a pas pu être ajouté au graphe", hr);
- IPin * pPinEntree = NULL;
+ CComPtr pPinEntree;
hr = cherche_pin(pEPGFilter, PINDIR_INPUT, pPinEntree);
- if (FAILED(hr) || pEPGFilter == NULL) {
- erreur(L"La broche d'entrée EPG n'a pas été trouvée", hr);
- return hr;
- }
+ if (FAILED(hr))
+ return erreur(L"La broche d'entrée EPG n'a pas été trouvée", hr);
hr = pGraph->ConnectDirect(pEpgPin, pPinEntree, NULL);
- pPinEntree->Release();
- if (FAILED(hr)) {
- erreur(L"La broche d'entrée EPG n'a pas pu être connectée", hr);
- return hr;
- }
+ if (FAILED(hr))
+ return erreur(L"La broche d'entrée EPG n'a pas pu être connectée", hr);
}
- IMPEG2PIDMap * pMapEpg;
- hr = pEpgPin->QueryInterface(&pMapEpg);
- if (SUCCEEDED(hr)) {
- ULONG pid = p_pid_EIT;
+ CComQIPtr pMapEpg(pEpgPin);
- pMapEpg->MapPID(1, &pid, MEDIA_MPEG2_PSI);
- pMapEpg->Release();
- }
- pEpgPin->Release();
+ if (!pMapEpg)
+ return E_NOINTERFACE;
+ ULONG pid = p_pid_EIT;
+
+ pMapEpg->MapPID(1, &pid, MEDIA_MPEG2_PSI);
return hr;
}
static HRESULT render_pmtfilter(IMpeg2Demultiplexer * pMpeg2Demux)
{
- IPin * pPmtPin;
+ CComPtr pPmtPin;
AM_MEDIA_TYPE am;
am.majortype = MEDIATYPE_MPEG2_SECTIONS;
@@ -892,119 +799,85 @@
am.pbFormat = NULL;
HRESULT hr = pMpeg2Demux->CreateOutputPin(&am, L"pmt", &pPmtPin);
- if (FAILED(hr)) {
- erreur(L"La broche PMT n'a pas pu être créée", hr);
- return hr;
- }
+ if (FAILED(hr))
+ return erreur(L"La broche PMT n'a pas pu être créée", hr);
+
// add mpeg2
{
- // CLSID clsid = {6, 7, 8, 9, 10, 11, 12, 13, 14};
- CPMTFilter * pPMTFilter =
+ CComPtr pPMTFilter =
dynamic_cast(CPMTFilter::CreateInstance(NULL, &hr)); // new CPMTFilter(clsid, &hr);
- if (FAILED(hr)) {
- erreur(L"Le filtre PMT n'a pas pu être créé", hr);
- return hr;
- }
+ if (FAILED(hr))
+ return erreur(L"Le filtre PMT n'a pas pu être créé", hr);
hr = pGraph->AddFilter(pPMTFilter, CPMTFilter::szFilterName);
- if (FAILED(hr)) {
- erreur(L"Le filtre PMT n'a pas pu être ajouté au graphe", hr);
- return hr;
- }
+ if (FAILED(hr))
+ return erreur(L"Le filtre PMT n'a pas pu être ajouté au graphe", hr);
- IPin * pPinEntree = NULL;
+ CComPtr pPinEntree;
hr = cherche_pin(pPMTFilter, PINDIR_INPUT, pPinEntree);
- if (FAILED(hr) || pPMTFilter == NULL)
- {
- erreur(L"La broche d'entrée PMT n'a pas été trouvée", hr);
- return hr;
- }
+ if (FAILED(hr))
+ return erreur(L"La broche d'entrée PMT n'a pas été trouvée", hr);
hr = pGraph->ConnectDirect(pPmtPin, pPinEntree, NULL);
- pPinEntree->Release();
- if (FAILED(hr)) {
- erreur(L"La broche d'entrée PMT n'a pas pu être connectée", hr);
- return hr;
- }
+ if (FAILED(hr))
+ return erreur(L"La broche d'entrée PMT n'a pas pu être connectée", hr);
}
- hr = pPmtPin->QueryInterface(&pMapPmt);
+ hr = pPmtPin.QueryInterface(&pMapPmt);
myprintf(L"%?erreur pMapPmt, hr=0x%08x\n", FAILED(hr), hr);
- pPmtPin->Release();
-
return hr;
}
static HRESULT cree_and_render_pins()
{
+ // crée les ports
- // cree les ports
+ CComQIPtr pMpeg2Demux(pDemux);
+ if (!pMpeg2Demux)
+ return erreur(L"L'interface du démultiplexeur n'a pas été trouvée", E_NOINTERFACE);
+
HRESULT hr;
- IMpeg2Demultiplexer * pMpeg2Demux;
- hr = pDemux->QueryInterface(&pMpeg2Demux);
+ if (FAILED(hr = render_mp2v(pMpeg2Demux)))
+ return erreur(L"Erreur lors du rendu de la broche vidéo MPEG2", hr);
- if (FAILED(hr)) {
- erreur(L"L'interface du démultiplexeur n'a pas été trouvée", hr);
- return hr;
- }
+ if (FAILED(hr = render_son(pMpeg2Demux)))
+ return erreur(L"Erreur lors du rendu de la broche audio MPEG2", hr);
- if (FAILED(hr = render_mp2v(pMpeg2Demux))) {
- erreur(L"Erreur lors du rendu de la broche vidéo MPEG2", hr);
- return hr;
- }
+ if (FAILED(hr = render_ac3(pMpeg2Demux)))
+ return erreur(L"Erreur lors du rendu de la broche audio AC3", hr);
- if (FAILED(hr = render_son(pMpeg2Demux))) {
- erreur(L"Erreur lors du rendu de la broche audio MPEG2", hr);
- return hr;
- }
+ if (FAILED(hr = render_psi(pMpeg2Demux)))
+ return erreur(L"Erreur lors du rendu de la broche PSI", hr);
- if (FAILED(hr = render_ac3(pMpeg2Demux))) {
- erreur(L"Erreur lors du rendu de la broche audio AC3", hr);
- return hr;
- }
+ if (FAILED(hr = render_epgfilter(pMpeg2Demux)))
+ return erreur(L"Erreur lors du rendu de la broche EPG", hr);
- if (FAILED(hr = render_psi(pMpeg2Demux))) {
- erreur(L"Erreur lors du rendu de la broche PSI", hr);
- return hr;
- }
+ if (FAILED(hr = render_pmtfilter(pMpeg2Demux)))
+ return erreur(L"Erreur lors du rendu de la broche PMT", hr);
- if (FAILED(hr = render_epgfilter(pMpeg2Demux))) {
- erreur(L"Erreur lors du rendu de la broche EPG", hr);
- return hr;
- }
-
- if (FAILED(hr = render_pmtfilter(pMpeg2Demux))) {
- erreur(L"Erreur lors du rendu de la broche PMT", hr);
- return hr;
- }
-
// fini
- pMpeg2Demux->Release();
-
return hr;
}
HRESULT build_graph(void)
{
int res;
- // créer le graph
+ // créer le graphe
- HRESULT hr = CoCreateInstance(CLSID_FilterGraph, NULL, CLSCTX_INPROC_SERVER,
- IID_IFilterGraph2, (void **)&pGraph);
- if (FAILED(hr) ) {
- erreur(L"Pas réussi à créer le graphe DirectShow !", hr);
- return hr;
- }
+ HRESULT hr = pGraph.CoCreateInstance(CLSID_FilterGraph, NULL, CLSCTX_INPROC_SERVER);
+ if (FAILED(hr) )
+ return erreur(L"Pas réussi à créer le graphe DirectShow !", hr);
+
// on logge
#if LOG_DSHOW
logFile = CreateFile(L"log_file.txt", GENERIC_WRITE, FILE_SHARE_READ, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
@@ -1015,15 +888,13 @@
#if EXPORT_GRAPH
hr = AddToRot();
- if (FAILED(hr)) {
- erreur(L"Échec de l'exportation du graphe", hr);
- return hr;
- }
+ if (FAILED(hr))
+ return erreur(L"Échec de l'exportation du graphe", hr);
#endif // #if EXPORT_GRAPH
{
// filtre dvb-t
- IBaseFilter * pNetworkProvider =
+ CComPtr pNetworkProvider =
dynamic_cast(CNetworkProvider::CreateInstance(NULL, &hr));
if (SUCCEEDED(hr))
@@ -1033,12 +904,11 @@
return hr;
}
- IBaseFilter * pAvantDemux;
+ CComPtr pAvantDemux;
res = filtre_compat(pNetworkTuner);
if (res == 1) {
-
// PCI
hr = pGraph->AddFilter(pNetworkTuner, nom_tuner);
@@ -1068,55 +938,38 @@
}
pAvantDemux = pReceiverComponent;
- pAvantDemux->AddRef();
-
} else if (res == 2) {
-
// USB
// connect USB
hr = pGraph->AddFilter(pNetworkTuner, nom_tuner);
- if (FAILED(hr)) {
- erreur(L"Échec de l'insertion du filtre Tuner USB", hr);
- return hr;
- }
+ if (FAILED(hr))
+ return erreur(L"Échec de l'insertion du filtre Tuner USB", hr);
hr = connect_filters(pNetworkProvider, pNetworkTuner);
- if (FAILED(hr)) {
- erreur(L"Tuner USB non compatible, veuillez effacer \"config.ini\" et redémarrer", hr);
- return hr;
- }
+ if (FAILED(hr))
+ return erreur(L"Tuner USB non compatible, veuillez effacer \"config.ini\" et redémarrer", hr);
pAvantDemux = pNetworkTuner;
- pAvantDemux->AddRef();
-
-
- } else {
+ } else
return E_FAIL;
- }
hr = getFrequencyFilter(pNetworkTuner);
- if (FAILED(hr) || pBDAFreq == NULL) {
- erreur(L"L'interface de changement de fréquence n'a pas été trouvée", hr);
- return hr;
- }
+ if (FAILED(hr))
+ return erreur(L"L'interface de changement de fréquence n'a pas été trouvée", hr);
hr = getSignalStatistics(pNetworkTuner);
- if (FAILED(hr) || pStats == NULL) {
- erreur(L"L'interface de qualité du signal n'a pas été trouvée", hr);
- return hr;
- }
+ if (FAILED(hr))
+ return erreur(L"L'interface de qualité du signal n'a pas été trouvée", hr);
// ajoute pGrabber filter
{
// connect 3
- IBaseFilter *filtrePrec = pAvantDemux;
- filtrePrec->AddRef();
- IBaseFilter * pGrabber;
-
+ CComPtr filtrePrec = pAvantDemux;
for (int i=0; i pGrabber;
+ wchar_t nom[20];
swprintf_s(nom, _countof(nom), L"Grabber %u", i);
hr = create_and_add_filter(CLSID_SampleGrabber, nom, pGrabber);
@@ -1124,12 +977,10 @@
return hr;
hr = connect_filters(filtrePrec, pGrabber);
- if (FAILED(hr)) {
- erreur(L"Le grabber n'a pas pu être connecté à la carte TNT, veuillez effacer \"config.ini\" et redémarrer", hr);
- return hr;
- }
+ if (FAILED(hr))
+ return erreur(L"Le grabber n'a pas pu être connecté à la carte TNT, veuillez effacer \"config.ini\" et redémarrer", hr);
- filtrePrec->Release();
+ filtrePrec.Release();
enregistrements_actuels[i].query(pGrabber);
filtrePrec = pGrabber;
}
@@ -1140,16 +991,10 @@
if (FAILED(hr))
return hr;
- hr = connect_filters(pGrabber, pDemux);
- if (FAILED(hr)) {
- erreur(L"Le grabber n'a pas pu être connecté au démultiplexeur, veuillez effacer \"config.ini\" et redémarrer", hr);
- return hr;
- }
-
- pGrabber->Release();
+ hr = connect_filters(filtrePrec, pDemux);
+ if (FAILED(hr))
+ return erreur(L"Le grabber n'a pas pu être connecté au démultiplexeur, veuillez effacer \"config.ini\" et redémarrer", hr);
}
-
- pAvantDemux->Release();
}
// fin des recherches, ajoute tout dans le graph
@@ -1164,10 +1009,9 @@
// derniers trucs
- hr = pGraph->QueryInterface(&pControl);
- if (FAILED(hr)) {
+ hr = pGraph.QueryInterface(&pControl);
+ if (FAILED(hr))
return hr;
- }
hr = pControl->Run();
Modifié: trunk/graph.h
===================================================================
--- trunk/graph.h 2008-11-09 22:21:51 UTC (rev 138)
+++ trunk/graph.h 2008-11-11 00:27:20 UTC (rev 139)
@@ -29,38 +29,36 @@
#include
-#define free_interface(X) if (X) { X->Release(); X=NULL;}
-
HRESULT build_graph(void); // retourne S_OK = pas d'erreur, != S_OK = erreur
void clean_dshow(void);
HRESULT init_vmr(void);
-extern IMpeg2Data * pMpeg2Data;
+extern CComPtr pMpeg2Data;
-extern IFilterGraph2 * pGraph;
+extern CComPtr pGraph;
-extern IBaseFilter * pNetworkTuner;
-extern IBaseFilter * pReceiverComponent;
+extern CComPtr pNetworkTuner;
+extern CComPtr pReceiverComponent;
-extern MyV(IVMRWindowlessControl) * pVMRControl;
+extern CComPtr pVMRControl;
-extern IBDA_SignalStatistics * pStats;
-extern IBDA_DeviceControl * pBDAControl;
-extern IBDA_FrequencyFilter * pBDAFreq;
+extern CComPtr pStats;
+extern CComPtr pBDAControl;
+extern CComPtr pBDAFreq;
-extern IMPEG2PIDMap * pMapMPEG2;
-extern IMPEG2PIDMap * pMapSound;
-extern IMPEG2PIDMap * pMapAc3;
-extern IMPEG2PIDMap * pMapPmt;
+extern CComPtr pMapMPEG2;
+extern CComPtr pMapSound;
+extern CComPtr pMapAc3;
+extern CComPtr pMapPmt;
-extern IBaseFilter * pVMR;
-extern IBaseFilter * pDSound;
-extern IBaseFilter * pDSoundAc3;
+extern CComPtr pVMR;
+extern CComPtr pDSound;
+extern CComPtr pDSoundAc3;
-extern IBaseFilter * pVideoCodec;
-extern IBaseFilter * pAudioCodec;
-extern IBaseFilter * pAc3Codec;
+extern CComPtr pVideoCodec;
+extern CComPtr pAudioCodec;
+extern CComPtr pAc3Codec;
-extern IBaseFilter * pDemux;
+extern CComPtr pDemux;
extern bool use_vmr_deinterlace;
Modifié: trunk/ini.cpp
===================================================================
--- trunk/ini.cpp 2008-11-09 22:21:51 UTC (rev 138)
+++ trunk/ini.cpp 2008-11-11 00:27:20 UTC (rev 139)
@@ -286,7 +286,7 @@
HRESULT hr = xml.charge(fileName);
- if (hr != S_OK) {
+ if (FAILED(hr)) {
return 1;
}
@@ -458,7 +458,7 @@
HRESULT hr = xml.charge(fileName);
- if (hr != S_OK) {
+ if (FAILED(hr)) {
return 1;
}
@@ -845,7 +845,7 @@
**/
bool check_config(void)
{
- pNetworkTuner = get_tuner(KSCATEGORY_BDA_NETWORK_TUNER, nom_tuner);
+ get_tuner(KSCATEGORY_BDA_NETWORK_TUNER, nom_tuner, pNetworkTuner);
if (pNetworkTuner == NULL) {
return false;
@@ -853,26 +853,19 @@
int res = filtre_compat(pNetworkTuner);
if (res == 1) { // PCI
- pReceiverComponent = get_tuner(KSCATEGORY_BDA_RECEIVER_COMPONENT, nom_receiver);
+ get_tuner(KSCATEGORY_BDA_RECEIVER_COMPONENT, nom_receiver, pReceiverComponent);
if (filtre_compat(pReceiverComponent) != 0) {
return true;
} else {
- pNetworkTuner->Release();
- pNetworkTuner = NULL;
-
- if (pReceiverComponent) {
- pReceiverComponent->Release();
- pReceiverComponent = NULL;
- }
-
+ pNetworkTuner.Release();
+ pReceiverComponent.Release();
return false;
}
} else if (res == 2) { // USB
return true;
} else {
- pNetworkTuner->Release();
- pNetworkTuner = NULL;
+ pNetworkTuner.Release();
return false;
}
}
Modifié: trunk/main.cpp
===================================================================
--- trunk/main.cpp 2008-11-09 22:21:51 UTC (rev 138)
+++ trunk/main.cpp 2008-11-11 00:27:20 UTC (rev 139)
@@ -1199,28 +1199,26 @@
}
}
-static void create_property_dialog(IBaseFilter * pFilter, LPCOLESTR nom)
+static void create_property_dialog(CComPtr & pFilter, LPCOLESTR nom)
{
- if (pFilter == NULL) {
+ if (!pFilter) {
affiche_erreurs(L"Il faut d'abord configurer un filtre et redémarrer l'application");
return;
}
- ISpecifyPropertyPages * pPages;
- HRESULT hr = pFilter->QueryInterface(&pPages);
+ CComQIPtr pPages(pFilter);
- if (FAILED(hr)) {
- affiche_erreurs(L"Ce filtre n'a pas de page de propriétés", hr);
+ if (!pPages) {
+ affiche_erreurs(L"Ce filtre n'a pas de page de propriétés", E_NOINTERFACE);
return;
}
- IUnknown * pUnk;
- hr = pPages->QueryInterface(&pUnk);
+ CComPtr pUnk(pPages);
- if (SUCCEEDED(hr)) {
+ if (pUnk) {
CAUUID caGUID;
- hr = pPages->GetPages(&caGUID);
+ HRESULT hr = pPages->GetPages(&caGUID);
if (SUCCEEDED(hr)) {
LCID lcid = GetUserDefaultLCID();
@@ -1233,7 +1231,7 @@
10,
nom,
1,
- &pUnk,
+ &pUnk.p,
caGUID.cElems,
caGUID.pElems,
lcid,
@@ -1247,11 +1245,7 @@
affiche_erreurs(L"Erreur lors de la création de la page de propriétés", hr);
}
}
-
- pUnk->Release();
}
- pPages->Release();
-
}
static void traite_numero(int nb)
@@ -1531,7 +1525,7 @@
LPWSTR wsVersion = new wchar_t[taille + 2];
swprintf_s(wsVersion, taille + 2, L"%S", versionInternet);
CXMLWrapper xml;
- if (xml.charge_xml(wsVersion) == S_OK) {
+ if (SUCCEEDED(xml.charge_xml(wsVersion))) {
CXMLElement root = xml.getDocElement();
@@ -1664,16 +1658,14 @@
{
POINT ar = {4, 3}; // (valeurs par défaut)
- if (pVMR != NULL) { // pVMR pas toujours défini à cet endroit
- IPin * pPin = NULL;
- HRESULT hr = cherche_pin(pVMR, PINDIR_INPUT, pPin);
+ if (pVMR) { // pVMR pas toujours défini à cet endroit
+ CComPtr pPin;
+ HRESULT hr = cherche_pin(pVMR, PINDIR_INPUT, pPin);
- if (SUCCEEDED(hr) && pPin != NULL) {
+ if (SUCCEEDED(hr)) {
AM_MEDIA_TYPE am;
hr = pPin->ConnectionMediaType(&am);
- pPin->Release();
-
if (SUCCEEDED(hr)) {
VIDEOINFOHEADER2 * vih = (VIDEOINFOHEADER2 *)am.pbFormat;
@@ -2713,7 +2705,7 @@
myprintf(L"Compile le : %S %S\n", __DATE__, __TIME__);
myprintf(L"\tVista build: %d\n", VISTA + 0);
- myprintf(L"Tuner : %s\nRécepteur : %s\nMPEG2 : %s\nAudio : %s\nAC3 : %s\nVille : %s\n",
+ myprintf(L"Tuner : %s\nRécepteur : %s\nMPEG2 : %s\nAudio : %s\nAC3 : %s\nVille : %s\n",
nom_tuner,
nom_receiver,
filtreMPEG2,
@@ -2880,8 +2872,12 @@
continue;
} else if (FAILED(hr = InitDshow())) {
clean_dshow();
- affiche_erreurs(L"Erreur lors de l'initialisation.\nVeuillez corriger la configuration.", hr);
+ affiche_erreurs(L"Erreur lors de l'initialisation.\nVeuillez corriger la configuration.", hr);
config_ok = false;
+
+ // Appeler une nouvelle fois, car certains filtres trouvent très malin d'appeler
+ // CoUninitialize pour se protéger des usages non autorisés :
+ CoInitializeEx(NULL,COINIT_MULTITHREADED);
}
} while (!config_ok);
@@ -2931,7 +2927,7 @@
update_record_menus(hMainWnd);
}
}
-
+
hMainMenu = GetMenu(hWnd);
/**
Modifié: trunk/network.cpp
===================================================================
--- trunk/network.cpp 2008-11-09 22:21:51 UTC (rev 138)
+++ trunk/network.cpp 2008-11-11 00:27:20 UTC (rev 139)
@@ -1,24 +1,24 @@
-/*
- * network.cpp
- * Copyright (C) 2006 Pouchin
- *
- * This file is part of Pouchin TV, a free DVB-T viewer.
- * See http://pouchinteve.free.fr/ for updates.
- *
- * Pouchin TV is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * Pouchin TV is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
+/*
+ * network.cpp
+ * Copyright (C) 2006 Pouchin
+ *
+ * This file is part of Pouchin TV, a free DVB-T viewer.
+ * See http://pouchinteve.free.fr/ for updates.
+ *
+ * Pouchin TV is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * Pouchin TV is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
#include "network.h"
#include "base.h"
@@ -39,7 +39,8 @@
HRESULT CPinBidon::CheckMediaType(const CMediaType *pmt)
{
// myprintf(L"CheckMediaType\n");
- if ( *pmt->Type() == KSDATAFORMAT_TYPE_BDA_ANTENNA) return S_OK;
+ if (*pmt->Type() == KSDATAFORMAT_TYPE_BDA_ANTENNA)
+ return S_OK;
return S_FALSE;
}
@@ -83,7 +84,7 @@
*phr = S_OK;
myprintf(TEXT("%s construit\n"), szFilterName);
}
- }
+ }
}
CNetworkProvider::~CNetworkProvider()
@@ -99,7 +100,7 @@
CNetworkProvider *pNewFilter = new CNetworkProvider(pUnk, phr);
if (phr) {
- if (pNewFilter == NULL)
+ if (pNewFilter == NULL)
*phr = E_OUTOFMEMORY;
else
*phr = S_OK;
Modifié: trunk/pmtfilter.cpp
===================================================================
--- trunk/pmtfilter.cpp 2008-11-09 22:21:51 UTC (rev 138)
+++ trunk/pmtfilter.cpp 2008-11-11 00:27:20 UTC (rev 139)
@@ -97,7 +97,8 @@
HRESULT CPMTFilter::CheckMediaType(const CMediaType * pmt)
{
- if ( *pmt->Type() == MEDIATYPE_MPEG2_SECTIONS) return S_OK;
+ if ( *pmt->Type() == MEDIATYPE_MPEG2_SECTIONS)
+ return S_OK;
return S_FALSE;
}
Modifié: trunk/record.cpp
===================================================================
--- trunk/record.cpp 2008-11-09 22:21:51 UTC (rev 138)
+++ trunk/record.cpp 2008-11-11 00:27:20 UTC (rev 139)
@@ -105,19 +105,17 @@
return after;
}
-void Enregistrement::query(IBaseFilter * pGrabber)
+void Enregistrement::query(CComPtr & pGrabber)
{
-
-
- if (pSample==NULL) {
- HRESULT hr = pGrabber->QueryInterface(&pSample);
+ if (!pSample) {
+ HRESULT hr = pGrabber.QueryInterface(&pSample);
myprintf(L"%?erreur query pSample, hr=0x%08x\n", FAILED(hr), hr);
}
}
-void Enregistrement::free()
+void Enregistrement::release()
{
- free_interface(pSample);
+ pSample.Release();
}
/**
Modifié: trunk/record.h
===================================================================
--- trunk/record.h 2008-11-09 22:21:51 UTC (rev 138)
+++ trunk/record.h 2008-11-11 00:27:20 UTC (rev 139)
@@ -42,10 +42,10 @@
class Enregistrement : public RecordInfo {
public:
- ISampleGrabber * pSample;
+ CComPtr pSample;
//
// Mini-constructeur :
- Enregistrement() : pSample(NULL) {}
+ Enregistrement() {}
//
bool recording() const {return sidChaine >0;}
bool isChannel(WORD sidCh) const {return sidChaine == sidCh;}
@@ -55,8 +55,8 @@
// Prise en compte d'une programmation affectant une chaîne déjà en cours d'enregistrement
bool modify_prog(Programme * pProg);
- void query(IBaseFilter * pGrabber);
- void free();
+ void query(CComPtr & pGrabber);
+ void release();
// Calcul du temps restant avant fin enregistrement en millisecondes.
// L'heure de référence (en principe l'heure système) doit être passée en paramètre.
Modifié: trunk/recprog.cpp
===================================================================
--- trunk/recprog.cpp 2008-11-09 22:21:51 UTC (rev 138)
+++ trunk/recprog.cpp 2008-11-11 00:27:20 UTC (rev 139)
@@ -302,9 +302,10 @@
// Ajout de cette programmation aux tâches programmées (retourne 'false' si échec)
bool Programme::ajouterTacheProgrammee(LPCWSTR username, LPCWSTR motdepasse) const
{
- WCHAR taskName[_countof(nom)+4];
- ITaskScheduler * pITS;
- SYSTEMTIME date = debut;
+ WCHAR taskName[_countof(nom)+4];
+ SYSTEMTIME date = debut;
+ CComPtr pTask;
+ HRESULT hr;
AddTime(date, -60*1000); // Soustraire 60 secondes
@@ -312,19 +313,20 @@
genereNomTache(taskName, _countof(taskName));
// Accède au planificateur pour supprimer la tâche si elle existe
- HRESULT hr = CoCreateInstance(CLSID_CTaskScheduler, NULL, CLSCTX_INPROC_SERVER, IID_ITaskScheduler, (void**)&pITS);
- if (FAILED(hr)) {
- myprintf(L"Erreur init task scheduler\n");
- return false;
- }
- // Supprime la tâche
- hr = pITS->Delete(taskName);
+ {
+ CComPtr pITS;
- // Crée la nouvelle tâche
- ITask * pTask;
+ hr = pITS.CoCreateInstance(CLSID_CTaskScheduler, NULL, CLSCTX_INPROC_SERVER);
+ if (FAILED(hr)) {
+ myprintf(L"Erreur init task scheduler\n");
+ return false;
+ }
+ // Supprime la tâche
+ pITS->Delete(taskName);
- hr = pITS->NewWorkItem(taskName, CLSID_CTask, IID_ITask, (IUnknown**)&pTask);
- pITS->Release();
+ // Crée la nouvelle tâche
+ hr = pITS->NewWorkItem(taskName, CLSID_CTask, IID_ITask, (IUnknown**)&pTask);
+ }
if (FAILED(hr)) {
myprintf(L"Erreur création tâche %s\n", taskName);
@@ -342,8 +344,8 @@
hr = pTask->SetAccountInformation(username, motdepasse);
if (SUCCEEDED(hr)) {
- WORD piNewTrigger;
- ITaskTrigger * pTaskTrigger;
+ WORD piNewTrigger;
+ CComPtr pTaskTrigger;
pTask->SetFlags(TASK_FLAG_DELETE_WHEN_DONE | TASK_FLAG_SYSTEM_REQUIRED);
pTask->SetMaxRunTime(INFINITE);
@@ -386,17 +388,11 @@
pTaskTrigger->SetTrigger(&Trig);
- IPersistFile * pPersistFile;
+ CComQIPtr pPersistFile(pTask);
- hr = pTask->QueryInterface(IID_IPersistFile, (void **)&pPersistFile);
- if (SUCCEEDED(hr)) {
+ if (pPersistFile)
pPersistFile->Save(NULL, TRUE);
- pPersistFile->Release();
- }
-
- pTaskTrigger->Release();
}
- pTask->Release();
return true;
}
@@ -437,12 +433,13 @@
bool Programme::supprimerTacheProgrammee() const
{
WCHAR taskName[_countof(nom)+4];
- ITaskScheduler * pITS;
// On génère le nom de la tâche :
genereNomTache(taskName, _countof(taskName));
- HRESULT hr = CoCreateInstance(CLSID_CTaskScheduler, NULL, CLSCTX_INPROC_SERVER, IID_ITaskScheduler, (void**)&pITS);
+ CComPtr pITS;
+
+ HRESULT hr = pITS.CoCreateInstance(CLSID_CTaskScheduler, NULL, CLSCTX_INPROC_SERVER);
if (FAILED(hr)) {
myprintf(L"Erreur init task scheduler\n");
return false;
@@ -450,8 +447,6 @@
// Supprime la tâche
pITS->Delete(taskName);
-
- pITS->Release();
return true;
}
@@ -567,7 +562,7 @@
**/
void set_timer_record()
{
- myprintf(L"Appel set_timer_record()\n");
+ // myprintf(L"Appel set_timer_record()\n");
SYSTEMTIME localtime;
long reste = DUREE_INFINIE;
@@ -589,7 +584,7 @@
// Si l'heure de début est déjà passée, on lance un timer qui aboutit immédiatement
long timer = min(max(reste, USER_TIMER_MINIMUM), DUREE_RECALCUL_TIMERS*1000);
- myprintf(L"Temps avant événement enreg : %i mS, timer = %i mS\n", reste, timer);
+ // myprintf(L"Temps avant événement enreg : %i mS, timer = %i mS\n", reste, timer);
SetTimer(hMainWnd, TIMER_DELAYED_RECORD, timer, NULL);
}
}
@@ -1835,7 +1830,7 @@
**/
bool do_record_events()
{
- myprintf(L"Appel do_record_events()\n");
+ // myprintf(L"Appel do_record_events()\n");
SYSTEMTIME localtime;
Modifié: trunk/search.cpp
===================================================================
--- trunk/search.cpp 2008-11-09 22:21:51 UTC (rev 138)
+++ trunk/search.cpp 2008-11-11 00:27:20 UTC (rev 139)
@@ -62,20 +62,17 @@
**/
void search_filters(GUID type, GUID subtype, HWND hItm)
{
- IFilterMapper2 * pMapper;
+ CComPtr pMapper;
- HRESULT hr = CoCreateInstance(CLSID_FilterMapper2,
- NULL, CLSCTX_INPROC, IID_IFilterMapper2, (void **)&pMapper);
+ HRESULT hr = pMapper.CoCreateInstance(CLSID_FilterMapper2, NULL, CLSCTX_INPROC);
if (FAILED(hr)) {
myprintf(L"search_filters, 1, hr=0x%08x\n", hr);
return;
}
- GUID arrayInTypes[2];
- arrayInTypes[0] = type;
- arrayInTypes[1] = subtype;
+ GUID arrayInTypes[2] = {type, subtype};
- IEnumMoniker * pEnum;
+ CComPtr pEnum;
hr = pMapper->EnumMatchingFilters(
&pEnum,
@@ -97,53 +94,47 @@
if (FAILED(hr)) {
myprintf(L"search_filters, 2, hr=0x%08x\n", hr);
- pMapper->Release();
return;
}
// Enumerate the monikers.
- IMoniker *pMoniker;
ULONG cFetched;
- while (pEnum->Next(1, &pMoniker, &cFetched) == S_OK) {
- IPropertyBag * pPropBag;
- hr = pMoniker->BindToStorage(0, 0, IID_IPropertyBag, (void **)&pPropBag);
- if (SUCCEEDED(hr)) {
- // To retrieve the friendly name of the filter, do the following:
- VARIANT varName;
- VariantInit(&varName);
- hr = pPropBag->Read(L"FriendlyName", &varName, 0);
- if (SUCCEEDED(hr)) {
- // Display the name in your UI somehow.
- VarStr_helper vstr(varName);
- //myprintf(L"filtre : %s\n", vstr);
+ for (
+ CComPtr pMoniker;
+ pEnum->Next(1, &pMoniker, &cFetched)==S_OK;
+ pMoniker.Release()
+ ) {
+ CComPtr pPropBag;
- SendMessage(hItm, CB_ADDSTRING, 0, (LPARAM)vstr());
- }
- VariantClear(&varName);
- pPropBag->Release();
- }
- pMoniker->Release();
- }
+ if (FAILED(hr = pMoniker->BindToStorage(0, 0, IID_IPropertyBag, (void **)&pPropBag)))
+ continue;
- pEnum->Release();
+ // To retrieve the friendly name of the filter, do the following:
+ CComVariant varName;
- pMapper->Release();
+ if (FAILED(hr = pPropBag->Read(L"FriendlyName", &varName, 0)))
+ continue;
+ // Display the name in your UI somehow.
+ VarStr_helper vstr(varName);
+ //myprintf(L"filtre : %s\n", vstr);
+
+ SendMessage(hItm, CB_ADDSTRING, 0, (LPARAM)vstr());
+ }
}
-HRESULT get_filter(GUID type, GUID subtype, LPCWSTR nom, IBaseFilter * & pFilter)
+HRESULT get_filter(GUID type, GUID subtype, LPCWSTR nom, CComPtr & pFilter)
{
myprintf(L"get_filter: type={%08x-%04x-%04x-%012x}\n", type.Data1, type.Data2, type.Data3, type.Data4);
myprintf(L"\tsubtype={%08x-%04x-%04x-%012x}\n", subtype.Data1, subtype.Data2, subtype.Data3, subtype.Data4);
myprintf(L"\tnom=%s\n", nom);
- IFilterMapper2 * pMapper;
+ pFilter.Release(); // au cas où
- pFilter = NULL;
+ CComPtr pMapper;
- HRESULT hr = CoCreateInstance(CLSID_FilterMapper2, NULL, CLSCTX_INPROC,
- IID_IFilterMapper2, (void **)&pMapper);
+ HRESULT hr = pMapper.CoCreateInstance(CLSID_FilterMapper2, NULL, CLSCTX_INPROC);
if (FAILED(hr)) {
myprintf(L"get_filter, 1, hr=0x%08x\n", hr);
return hr;
@@ -153,7 +144,7 @@
arrayInTypes[0] = type;
arrayInTypes[1] = subtype;
- IEnumMoniker * pEnum;
+ CComPtr pEnum;
hr = pMapper->EnumMatchingFilters(
&pEnum,
@@ -174,129 +165,119 @@
if (FAILED(hr)) {
myprintf(L"get_filter, 2, hr=0x%08x\n", hr);
- pMapper->Release();
return hr;
}
// Enumerate the monikers.
- IMoniker *pMoniker;
ULONG cFetched;
- while (pFilter == NULL && pEnum->Next(1, &pMoniker, &cFetched) == S_OK) {
- IPropertyBag * pPropBag;
+ for (
+ CComPtr pMoniker;
+ !pFilter && pEnum->Next(1, &pMoniker, &cFetched)==S_OK;
+ pMoniker.Release()
+ ) {
+ CComPtr pPropBag;
+
hr = pMoniker->BindToStorage(0, 0, IID_IPropertyBag, (void **)&pPropBag);
+ if (FAILED(hr))
+ continue;
- if (SUCCEEDED(hr)) {
- // To retrieve the friendly name of the filter, do the following:
- VARIANT varName;
- VariantInit(&varName);
- hr = pPropBag->Read(L"FriendlyName", &varName, 0);
- if (SUCCEEDED(hr)) {
- // Display the name in your UI somehow.
- VarStr_helper vstr(varName);
+ // To retrieve the friendly name of the filter, do the following:
+ CComVariant varName;
- if (wcscmp(vstr(), nom)==0) {
- hr = pMoniker->BindToObject(NULL, NULL, IID_IBaseFilter, (void**)&pFilter);
- }
+ if (FAILED(hr = pPropBag->Read(L"FriendlyName", &varName, 0)))
+ continue;
+ // Display the name in your UI somehow.
+ VarStr_helper vstr(varName);
- }
- VariantClear(&varName);
- pPropBag->Release();
- }
- pMoniker->Release();
+ if (wcscmp(vstr(), nom)==0)
+ hr = pMoniker->BindToObject(NULL, NULL, IID_IBaseFilter, (void**)&pFilter);
}
- pEnum->Release();
- pMapper->Release();
-
return hr;
}
// 1er pin non connecté
-HRESULT cherche_pin(IBaseFilter * pFilter, PIN_DIRECTION dir, IPin * & result)
+HRESULT cherche_pin(CComPtr & pFilter, PIN_DIRECTION dir, CComPtr & result)
{
- IEnumPins * pEnumPins;
- HRESULT hr;
- IPin * curpin = NULL;
+ CComPtr pEnumPins;
+ HRESULT hr = pFilter->EnumPins(&pEnumPins);
- hr = pFilter->EnumPins(&pEnumPins);
if (FAILED(hr)) {
myprintf(L"cherche_pin, 1, hr=0x%08x\n", hr);
return hr;
}
- while (pEnumPins->Next(1, &curpin, NULL)==S_OK ) {
-
+ for (
+ CComPtr curpin;
+ (hr = pEnumPins->Next(1, &curpin, NULL))==S_OK;
+ curpin.Release()
+ ) {
PIN_DIRECTION direction;
curpin->QueryDirection(&direction);
if (direction == dir) {
#ifdef _DEBUG
- IPin * connected = NULL;
+ CComPtr connected;
+
curpin->ConnectedTo(&connected);
- if (connected == NULL) {
+ if (!connected) {
result = curpin;
break;
}
- connected->Release();
#else
result = curpin;
break;
#endif
}
- curpin->Release();
- curpin = NULL;
}
- pEnumPins->Release();
-
- return S_OK;
+ return !result ? E_FAIL : hr;
}
// 0 pas compat, 1 tuner, 2 receiver
-int filtre_compat(IBaseFilter * pFilter)
+int filtre_compat(CComPtr & pFilter)
{
int res = 0;
- if (pFilter == NULL) {
+ if (!pFilter)
return res;
- }
- IEnumPins *pEnumPins;
+ CComPtr pEnumPins;
+
pFilter->EnumPins(&pEnumPins);
- IPin *pPin;
- while(pEnumPins->Next(1, &pPin, NULL) == S_OK && res == 0) {
+ for (
+ CComPtr pPin;
+ res==0 && pEnumPins->Next(1, &pPin, NULL)==S_OK;
+ pPin.Release()
+ ) {
PIN_DIRECTION dir;
pPin->QueryDirection(&dir);
- if (dir == PINDIR_OUTPUT) {
+ if (dir != PINDIR_OUTPUT)
+ continue;
- IEnumMediaTypes * pEnumMedia;
+ CComPtr pEnumMedia;
- pPin->EnumMediaTypes(&pEnumMedia);
+ pPin->EnumMediaTypes(&pEnumMedia);
- AM_MEDIA_TYPE * am;
+ AM_MEDIA_TYPE * am;
- while(pEnumMedia->Next(1, &am, NULL) == S_OK && res == 0) {
- if (am->majortype == MEDIATYPE_Stream) {
-
- if (am->subtype == KSDATAFORMAT_TYPE_MPEG2_TRANSPORT) {
- res = 1;
- } else if (am->subtype == KSDATAFORMAT_SUBTYPE_BDA_MPEG2_TRANSPORT) {
- res = 2;
- }
-
+ while (res==0 && (pEnumMedia->Next(1, &am, NULL))==S_OK) {
+ if (am->majortype == MEDIATYPE_Stream) {
+ if (am->subtype == KSDATAFORMAT_TYPE_MPEG2_TRANSPORT) {
+ res = 1;
+ } else if (am->subtype == KSDATAFORMAT_SUBTYPE_BDA_MPEG2_TRANSPORT) {
+ res = 2;
}
-
- DeleteMediaType(am);
}
+
+ DeleteMediaType(am);
}
- pPin->Release();
}
- pEnumPins->Release();
return res;
}
@@ -304,108 +285,94 @@
HRESULT remplit_tuners(GUID guid, HWND hItm)
{
// Create the System Device Enumerator.
- ICreateDevEnum * pDevEnum;
- HRESULT hr = CoCreateInstance(CLSID_SystemDeviceEnum, NULL, CLSCTX_INPROC_SERVER,
- IID_ICreateDevEnum, (void **)&pDevEnum);
- if (FAILED(hr)) {
- myprintf(L"remplit_tuners, ICreateDevEnum : hr=0x%08x\n", hr);
+ CComPtr pDevEnum;
+
+ HRESULT hr = pDevEnum.CoCreateInstance(CLSID_SystemDeviceEnum, NULL, CLSCTX_INPROC_SERVER);
+ if (FAILED(hr))
return hr;
- }
- IEnumMoniker *pEnumMoniker = NULL;
+ CComPtr pEnumMoniker;
hr = pDevEnum->CreateClassEnumerator(guid, &pEnumMoniker, 0);
- if (FAILED(hr) || pEnumMoniker == NULL) {
- myprintf(L"remplit_tuners, erreur création Enum Moniker : hr=0x%08x\n", hr);
- pDevEnum->Release();
+ if (FAILED(hr) || !pEnumMoniker)
return hr;
- }
- IMoniker *pMoniker;
- while (pEnumMoniker->Next(1, &pMoniker, NULL) == S_OK) {
- IBaseFilter *pFilter;
+ for (
+ CComPtr pMoniker;
+ pEnumMoniker->Next(1, &pMoniker, NULL)==S_OK;
+ pMoniker.Release()
+ ) {
+ CComPtr pFilter;
HRESULT hr = pMoniker->BindToObject(0, 0, IID_IBaseFilter, (void**)&pFilter);
- if (SUCCEEDED(hr)) {
- if (filtre_compat(pFilter)) {
- IPropertyBag * pPropBag;
- if (SUCCEEDED(pMoniker->BindToStorage(0, 0, IID_IPropertyBag, (void **)&pPropBag))) {
- // To retrieve the friendly name of the filter, do the following:
- VARIANT varName;
- VariantInit(&varName);
- if (SUCCEEDED(pPropBag->Read(L"FriendlyName", &varName, 0))) {
- myprintf(L"remplit_tuner, Tuner : %s\n", varName.bstrVal);
- SendMessage(hItm, CB_ADDSTRING, 0, (LPARAM)varName.bstrVal);
- }
- VariantClear(&varName);
- pPropBag->Release();
- }
+ if (FAILED(hr) || filtre_compat(pFilter)==0)
+ continue;
- }
- pFilter->Release();
- }
+ CComPtr pPropBag;
- pMoniker->Release();
- }
+ if (FAILED(pMoniker->BindToStorage(0, 0, IID_IPropertyBag, (void **)&pPropBag)))
+ continue;
- pEnumMoniker->Release();
- pDevEnum->Release();
+ // To retrieve the friendly name of the filter, do the following:
+ CComVariant varName;
+ if (SUCCEEDED(pPropBag->Read(L"FriendlyName", &varName, 0))) {
+ myprintf(L"remplit_tuner, Tuner : %s\n", varName.bstrVal);
+ SendMessage(hItm, CB_ADDSTRING, 0, (LPARAM)varName.bstrVal);
+ }
+ }
+
return hr;
}
// renvoie le filtre à partir du nom
-IBaseFilter * get_tuner(GUID guid, wchar_t * nom)
+HRESULT get_tuner(GUID guid, LPCWSTR nom, CComPtr & pFilter)
{
+ pFilter.Release();
+
myprintf(L"get_tuner: guid={%08x-%04x-%04x-%012x}, nom=%s\n", guid.Data1, guid.Data2, guid.Data3, guid.Data4, nom);
+
// Create the System Device Enumerator.
- ICreateDevEnum * pDevEnum;
- HRESULT hr = CoCreateInstance(CLSID_SystemDeviceEnum, NULL, CLSCTX_INPROC_SERVER,
- IID_ICreateDevEnum, (void **)&pDevEnum);
+ CComPtr pDevEnum;
+
+ HRESULT hr = pDevEnum.CoCreateInstance(CLSID_SystemDeviceEnum, NULL, CLSCTX_INPROC_SERVER);
+
if (FAILED(hr)) {
myprintf(L"get_tuner, ICreateDevEnum : hr=0x%08x\n", hr);
- return NULL;
+ return hr;
}
- IEnumMoniker *pEnumMoniker = NULL;
+ CComPtr pEnumMoniker;
hr = pDevEnum->CreateClassEnumerator(guid, &pEnumMoniker, 0);
- if (FAILED(hr) || pEnumMoniker == NULL) {
+ if (FAILED(hr) || !pEnumMoniker) {
myprintf(L"get_tuner, erreur création Enum Moniker : hr=0x%08x\n", hr);
- pDevEnum->Release();
- return NULL;
+ return hr;
}
- IMoniker *pMoniker;
- IBaseFilter * pFilter = NULL;
+ for (
+ CComPtr pMoniker;
+ !pFilter && pEnumMoniker->Next(1, &pMoniker, NULL)==S_OK;
+ pMoniker.Release()
+ ) {
+ CComPtr pPropBag;
- while (pEnumMoniker->Next(1, &pMoniker, NULL) == S_OK && pFilter == NULL) {
- IPropertyBag * pPropBag;
-
if (SUCCEEDED(pMoniker->BindToStorage(0, 0, IID_IPropertyBag, (void **)&pPropBag))) {
// To retrieve the friendly name of the filter, do the following:
- VARIANT varName;
- VariantInit(&varName);
- if (SUCCEEDED(pPropBag->Read(L"FriendlyName", &varName, 0))) {
- VarStr_helper vstr(varName);
- myprintf(L"get_tuner, Tuner : %s\n", varName.bstrVal);
- if (wcscmp(vstr(), nom)==0) {
+ CComVariant varName;
- hr = pMoniker->BindToObject(NULL, NULL, IID_IBaseFilter, (void**)&pFilter);
- }
+ if (FAILED(pPropBag->Read(L"FriendlyName", &varName, 0)))
+ continue;
- }
- VariantClear(&varName);
- pPropBag->Release();
- }
+ VarStr_helper vstr(varName);
- pMoniker->Release();
+ myprintf(L"get_tuner, Tuner : %s\n", varName.bstrVal);
+ if (wcscmp(vstr(), nom)==0)
+ hr = pMoniker->BindToObject(NULL, NULL, IID_IBaseFilter, (void**)&pFilter);
+ }
}
- pEnumMoniker->Release();
- pDevEnum->Release();
-
- return pFilter;
+ return hr;
}
Modifié: trunk/search.h
===================================================================
--- trunk/search.h 2008-11-09 22:21:51 UTC (rev 138)
+++ trunk/search.h 2008-11-11 00:27:20 UTC (rev 139)
@@ -29,12 +29,13 @@
//IBaseFilter * search_mpeg2(IEnumMoniker *pEnumMoniker, GUID subtype, GUID format);
-HRESULT cherche_pin(IBaseFilter * pFilter, PIN_DIRECTION dir, IPin * & result);
+HRESULT cherche_pin(CComPtr & pFilter, PIN_DIRECTION dir, CComPtr & result);
void search_filters(GUID type, GUID subtype, HWND hItm);
-HRESULT get_filter(GUID type, GUID subtype, LPCWSTR nom, IBaseFilter * & pFilter);
+HRESULT get_filter(GUID type, GUID subtype, LPCWSTR nom, CComPtr & pFilter);
HRESULT remplit_tuners(GUID guid, HWND hItm);
-IBaseFilter * get_tuner(GUID guid, wchar_t * nom);
-int filtre_compat(IBaseFilter * pFilter);
+HRESULT get_tuner(GUID guid, LPCWSTR nom, CComPtr & pFilter);
+int filtre_compat(CComPtr & pFilter);
+
extern BOOL exact_match;
Modifié: trunk/utils.h
===================================================================
--- trunk/utils.h 2008-11-09 22:21:51 UTC (rev 138)
+++ trunk/utils.h 2008-11-11 00:27:20 UTC (rev 139)
@@ -42,16 +42,17 @@
#include
// Conversions 'printf' entre CHAR ou WCHAR vers TCHAR
+// (3ème caractères en minuscules, sinon ça fait conflit avec certaines macros ATL)
#ifdef _UNICODE
- #define T2A "S" // TCHAR vers CHAR
- #define T2W L"s" // TCHAR vers WCHAR
- #define A2T L"S" // CHAR vers TCHAR
- #define W2T L"s" // WCHAR vers TCHAR
+ #define T2a "S" // TCHAR vers CHAR
+ #define T2w L"s" // TCHAR vers WCHAR
+ #define A2t L"S" // CHAR vers TCHAR
+ #define W2t L"s" // WCHAR vers TCHAR
#else
- #define T2A "s" // TCHAR vers CHAR
- #define T2W L"S" // TCHAR vers WCHAR
- #define A2T "s" // CHAR vers TCHAR
- #define W2T "S" // WCHAR vers TCHAR
+ #define T2a "s" // TCHAR vers CHAR
+ #define T2w L"S" // TCHAR vers WCHAR
+ #define A2t "s" // CHAR vers TCHAR
+ #define W2t "S" // WCHAR vers TCHAR
#endif
// Structure pour la sauvegarde de la position des fenêtres :
Modifié: trunk/xml.cpp
===================================================================
--- trunk/xml.cpp 2008-11-09 22:21:51 UTC (rev 138)
+++ trunk/xml.cpp 2008-11-11 00:27:20 UTC (rev 139)
@@ -29,7 +29,8 @@
#include "xml.h"
-CXMLElement::CXMLElement(IXMLDOMElement * element) : m_ele(element)
+CXMLElement::CXMLElement(IXMLDOMElement * element) :
+ m_ele(element)
{
// myprintf(L"élément contruit\n");
}
@@ -37,20 +38,17 @@
CXMLElement::~CXMLElement()
{
- m_ele->Release();
-
// myprintf(L"élément détruit\n");
}
std::vector CXMLElement::getChildren()
{
std::vector vect;
+ CComPtr pChildList;
- IXMLDOMNodeList * pChildList = NULL;
m_ele->get_childNodes(&pChildList);
if (pChildList) {
-
long length;
pChildList->get_length(&length);
@@ -59,18 +57,15 @@
pChildList->get_item(i, &pNode);
-
vect.push_back(new CXMLNode(pNode));
}
-
-
- pChildList->Release();
}
return vect;
}
-CXMLNode::CXMLNode(IXMLDOMNode * element) : m_node(element)
+CXMLNode::CXMLNode(IXMLDOMNode * element) :
+ m_node(element)
{
// myprintf(L"noeud construit\n");
}
@@ -78,8 +73,6 @@
CXMLNode::~CXMLNode()
{
- m_node->Release();
-
// myprintf(L"noeud détruit\n");
}
@@ -87,7 +80,9 @@
{
int rep = 0;
bool trouve = false;
- IXMLDOMNodeList * pChildList = NULL;
+
+ CComPtr pChildList;
+
m_node->get_childNodes(&pChildList);
if (pChildList) {
@@ -96,7 +91,7 @@
pChildList->get_length(&length);
for (long i=0; i pNode;
pChildList->get_item(i, &pNode);
BSTR bstr;
@@ -112,9 +107,7 @@
}
SysFreeString(bstr);
- pNode->Release();
}
- pChildList->Release();
}
return rep;
}
@@ -122,16 +115,16 @@
void CXMLNode::getStr(const wchar_t * nom, wchar_t * str, size_t size)
{
bool found = false;
- IXMLDOMNodeList * pChildList = NULL;
+ CComPtr pChildList;
+
m_node->get_childNodes(&pChildList);
if (pChildList) {
-
long length;
pChildList->get_length(&length);
for (long i=0; i pNode;
pChildList->get_item(i, &pNode);
BSTR bstr;
@@ -146,9 +139,7 @@
SysFreeString(txt);
}
SysFreeString(bstr);
- pNode->Release();
}
- pChildList->Release();
}
}
@@ -166,7 +157,8 @@
* Récupère des enfants à partir d'un nom
**/
void CXMLNode::getChildrenByName(const wchar_t *nom, CXMLNode **noeud) {
- IXMLDOMNodeList * pChildList = NULL;
+ CComPtr pChildList;
+
m_node->get_childNodes(&pChildList);
bool found = false;
@@ -177,7 +169,7 @@
pChildList->get_length(&length);
for (long i=0; i pNode;
pChildList->get_item(i, &pNode);
@@ -189,23 +181,19 @@
if (wcscmp(bstr, nom) == 0 && bHasChild) {
found = true;
- IXMLDOMNode *node = NULL;
+ CComPtr node;
+
pNode->cloneNode(VARIANT_TRUE, &node);
*noeud = new CXMLNode(node);
}
SysFreeString(bstr);
- pNode->Release();
-
}
- pChildList->Release();
}
-
}
CXMLWrapper::CXMLWrapper()
{
- CoCreateInstance(CLSID_DOMDocument,
- NULL, CLSCTX_INPROC_SERVER, IID_IXMLDOMDocument, (void**)&m_doc);
+ m_doc.CoCreateInstance(CLSID_DOMDocument, NULL, CLSCTX_INPROC_SERVER);
// myprintf(L"wrapper contruit\n");
}
@@ -213,26 +201,18 @@
CXMLWrapper::~CXMLWrapper()
{
- m_doc->Release();
-
// myprintf(L"wrapper détruit\n");
}
HRESULT CXMLWrapper::charge(const wchar_t * nom)
{
- VARIANT var;
- VARIANT_BOOL status;
+ CComVariant var;
+ VARIANT_BOOL status;
- VariantInit(&var);
-
var.vt = VT_BSTR;
var.bstrVal = SysAllocString(nom);
- HRESULT hr = m_doc->load(var, &status);
-
- VariantClear(&var);
-
- return hr;
+ return m_doc->load(var, &status);
}
/**
@@ -270,7 +250,7 @@
CXMLElement CXMLWrapper::getDocElement()
{
- IXMLDOMElement * pDOMElement;
+ CComPtr pDOMElement;
m_doc->get_documentElement(&pDOMElement);
Modifié: trunk/xml.h
===================================================================
--- trunk/xml.h 2008-11-09 22:21:51 UTC (rev 138)
+++ trunk/xml.h 2008-11-11 00:27:20 UTC (rev 139)
@@ -33,7 +33,7 @@
class CXMLNode
{
private:
- IXMLDOMNode * m_node;
+ CComPtr m_node;
public:
CXMLNode(IXMLDOMNode * node);
@@ -50,7 +50,7 @@
class CXMLElement
{
private:
- IXMLDOMElement * m_ele;
+ CComPtr m_ele;
public:
CXMLElement(IXMLDOMElement * element);
@@ -63,9 +63,7 @@
class CXMLWrapper
{
private:
- IXMLDOMDocument * m_doc;
-
-
+ CComPtr m_doc;
public:
CXMLWrapper();
~CXMLWrapper();
From pouchintv-dev at baysse.fr Tue Nov 11 14:47:23 2008
From: pouchintv-dev at baysse.fr (=?iso-8859-1?q?Liste_utilis=E9e_par_les_d=E9veloppeurs?=)
Date: Tue, 11 Nov 2008 14:47:23 +0100
Subject: [Pouchintv-dev] [PouchinTVMod] gingko | r139 - trunk
In-Reply-To: <20081111002721.4B5485F331@mail.baysse.fr>
References: <20081111002721.4B5485F331@mail.baysse.fr>
Message-ID: <49198CEB.7030005@baysse.fr>
Liste utilisée par les développeurs a écrit :
> Author: gingko
> Date: 2008-11-11 01:27:20 +0100 (mar, 11 nov 2008)
> New Revision: 139
>
> Modified:
> trunk/LCD.cpp
> trunk/base.cpp
> trunk/base.h
> trunk/channels.cpp
> trunk/graph.cpp
> trunk/graph.h
> trunk/ini.cpp
> trunk/main.cpp
> trunk/network.cpp
> trunk/pmtfilter.cpp
> trunk/record.cpp
> trunk/record.h
> trunk/recprog.cpp
> trunk/search.cpp
> trunk/search.h
> trunk/utils.h
> trunk/xml.cpp
> trunk/xml.h
> Log:
> Réécriture des déclarations d'instances d'objets issus des filtres DirectShow,
> ainsi que d'autres objets dérivés du modèle d'objets COM, de manière à utiliser
> les "smart pointers" définis dans la bibliothèques de modèles de classes
> (templates) ATL. Ces classes gérant automatiquement les ajouts et suppressions
> de références de ces objets (AddRef et Release), ceci permet de supprimer
> la plupart de ces instructions, tout en s'assurant d'une gestion optimale
> de ces objets avec réduction au minimum des risques de fuites de mémoires
> et d'objets non détruits.
> Ajout d'un nouvel appel redondant à "CoInitializeEx" en cas d'échec de
> de la création du graphe, en raison du fait que certains filtres DirectShow
> (Nero...) semblent s'autoprotéger contre les usages non autorisés en exécutant
> une instruction "CoUninitialize", ce qui compliquait sérieusement le retour
> subséquent au dialogue de configuration.
> Optimisation supplémentaire de la gestion des messages d'erreurs (via ajout d'une
> recopie du code d'erreur transmis à la fonction "erreur" vers la valeur de retour
> de cette fonction).
>
Salut,
je n'ai pas encore regardé les mais ta modification semble interdire
l'utilisation de Visual Studio Express, car les ATL ne sont pas gérées
par celui-ci
Et de plus, est-ce que les ATL ne nécessitent pas des dépendances
supplémentaires par rapport à un Windows de base ?
--
lolo_32
From pouchintv-dev at baysse.fr Sun Nov 16 15:59:52 2008
From: pouchintv-dev at baysse.fr (=?iso-8859-1?q?Liste_utilis=E9e_par_les_d=E9veloppeurs?=)
Date: Sun, 16 Nov 2008 15:59:52 +0100 (CET)
Subject: [Pouchintv-dev] [PouchinTVMod] gingko | r140 - trunk
Message-ID: <20081116145952.4649E5F3B7@mail.baysse.fr>
Author: gingko
Date: 2008-11-16 15:59:52 +0100 (dim, 16 nov 2008)
New Revision: 140
Added:
trunk/atlbase_ptvm.h
Modified:
trunk/Pouchin TV.vcproj
trunk/base.cpp
trunk/base.h
Log:
Ajout d'un jeu minimal de modèles de classes destinées à se substituer
aux modèles de classes (templates) ATL que j'avais commencé à utiliser
dans la précédente livraison. En effet, je me suis aperçu a posteriori
que ces modèles de classes n'étaient disponibles que dans la version
complète de Visual Studio 2005, et que sans ceux-ci, les utilisateurs
de Visual C++ Express 2005 ne pouvaient plus compiler le programme.
Les utilisateurs de Visual C++ Express 2005 peuvent utiliser ces définitions
en activant la macro "DONT_HAVE_ATL_TEMPLATES" dans le fichier "base.h".
Modification du projet principal pour référencer directement le dossier
"BaseClasses" inclus : ainsi, il n'est plus nécessaire d'inclure
ce dossier dans les répertoires d'inclusion globaux de l'environnement.
Modifié: trunk/Pouchin TV.vcproj
===================================================================
--- trunk/Pouchin TV.vcproj 2008-11-11 00:27:20 UTC (rev 139)
+++ trunk/Pouchin TV.vcproj 2008-11-16 14:59:52 UTC (rev 140)
@@ -53,12 +53,14 @@
UsePrecompiledHeader="0"
WarningLevel="4"
DebugInformationFormat="4"
+ DisableSpecificWarnings="4480"
/>
),
+ * to use with a modified version of this software.
+ * See http://pouchinteve.free.fr/ for the original project.
+ */
+
+#pragma once
+
+// Ce fichier contient des susbtituts minimaux aux modèles de classes
+// (templates) ATL normalement inclus dans Visual Studio 2005
+// édition professionnelle, mais non fournis dans Visual C++ 2005 Express.
+
+// Ces modèles contiennent les fonctionnalités minimales nécessaires
+// pour que le projet PouchinTV Mod puisse être compilé avec
+// Visual C++ 2005 Express.
+
+// Les utilisateurs de Visual C++ 2005 Express qui désireraient cependant
+// avoir un support plus complet de ces modèles de classes ATL peuvent
+// télécharger et installer le Windows Server 2003 SP1 Device Driver Kit
+// (nom du fichier = 1830_usa_ddk.iso) à l'adresse suivante :
+// http://www.microsoft.com/whdc/devtools/ddk/
+// Il convient ensuite d'ajouter les répertoires suivants dans la liste des
+// répertoires de VC++ :
+// - Fichiers include : \inc\atl30
+// - Fichiers bibliothèques : \lib\atl\i386
+// est le répertoire d'installation du DDK
+// (par défaut C:\WINDDK\3790.1830).
+
+template
+ class CComPtr
+{
+public:
+ IU * p;
+
+ CComPtr() : p(NULL) {
+ }
+ CComPtr(IU* q) : p(q) {
+ if (p) p->AddRef();}
+ CComPtr(const CComPtr & r) : p(r.p) {
+ if (p) p->AddRef();}
+ IU * operator -> () const {
+ return p;}
+ bool operator ! () const {
+ return p==NULL;}
+ IU** operator & () {
+ return &p;}
+ operator IU * () {
+ return p;}
+ void Release() {
+ IU* t=p; if (t) {p=NULL; t->Release();}}
+ IU* operator = (const IU* q) {
+ Release(); p=q; p->AddRef(); return p;}
+ CComPtr & operator = (const CComPtr & r) {
+ Release(); p=r.p; p->AddRef(); return *this;}
+ template HRESULT QueryInterface(QI** pp) const {
+ return p->QueryInterface(__uuidof(QI), (void**)pp);}
+ HRESULT CoCreateInstance(const GUID & g, IUnknown* u=NULL, unsigned long c=CLSCTX_ALL) {
+ return ::CoCreateInstance(g, u, c, __uuidof(IU), (void**)&p);}
+ ~CComPtr() {
+ Release();}
+};
+
+template
+ class CComQIPtr : public CComPtr
+{
+public:
+ CComQIPtr(IUnknown* q) {
+ if (q != NULL) q->QueryInterface(g, (void **)&p);}
+};
+
+class CComVariant : public VARIANT
+{
+public:
+ CComVariant()
+ {VariantInit(this);}
+ ~CComVariant()
+ {VariantClear(this);}
+};
Modifié: trunk/base.cpp
===================================================================
--- trunk/base.cpp 2008-11-11 00:27:20 UTC (rev 139)
+++ trunk/base.cpp 2008-11-16 14:59:52 UTC (rev 140)
@@ -81,5 +81,6 @@
MessageBox(hMainWnd, pszErrBuf, NULL, MB_ICONERROR);
delete pszErrBuf;
pszErrBuf = NULL;
+ lastRes = S_OK;
}
}
Modifié: trunk/base.h
===================================================================
--- trunk/base.h 2008-11-11 00:27:20 UTC (rev 139)
+++ trunk/base.h 2008-11-16 14:59:52 UTC (rev 140)
@@ -65,7 +65,20 @@
#pragma warning(disable:4995)
#include
+// Activer la définition suivante si les modèles de classes ATL ne sont
+// pas disponibles sur votre ordinateur (ce qui est normalement le cas
+// des utilisateurs de Visual C++ 2005 Express, sauf s'ils se sont procurés
+// ces classes depuis une autre source ; ils auront dans ce cas l'erreur suivante :
+// "fatal error C1083: Impossible d'ouvrir le fichier include : 'atlbase.h'" ;
+// voir commentaires dans le fichier atlbase_ptvm.h) :
+
+// #define DONT_HAVE_ATL_TEMPLATES
+
+#ifdef DONT_HAVE_ATL_TEMPLATES
+ #include "atlbase_ptvm.h"
+#else
#include
+#endif
#include "resource.h"
From pouchintv-dev at baysse.fr Thu Nov 20 13:15:06 2008
From: pouchintv-dev at baysse.fr (=?iso-8859-1?q?Liste_utilis=E9e_par_les_d=E9veloppeurs?=)
Date: Thu, 20 Nov 2008 13:15:06 +0100 (CET)
Subject: [Pouchintv-dev] [PouchinTVMod] gingko | r141 - trunk
Message-ID: <20081120121506.70A615F3A9@mail.baysse.fr>
Author: gingko
Date: 2008-11-20 13:15:06 +0100 (jeu, 20 nov 2008)
New Revision: 141
Modified:
trunk/Pouchin TV.vcproj
trunk/base.cpp
trunk/base.h
trunk/capture.cpp
trunk/capture.h
trunk/channels.cpp
trunk/channels.h
trunk/chanutils.cpp
trunk/chanutils.h
trunk/epg.cpp
trunk/graph.cpp
trunk/graph.h
trunk/ini.cpp
trunk/main.cpp
trunk/main.h
trunk/mpeg2defs.h
trunk/parse.cpp
trunk/record.cpp
trunk/recprog.cpp
trunk/sbuffer.cpp
trunk/sbuffer.h
trunk/search.cpp
trunk/settings.cpp
trunk/xml.cpp
Log:
Utilisation de types énumérés locaux pour désigner les types de flux
audio et vidéo pris en charge par PouchinTV Mod.
Suppression du descripteur "mpeg4_pid" dans les descripteurs de chaînes :
considérant qu'une chaîne n'a en principe qu'un seul flux vidéo principal,
il m'a semblé préférable d'utiliser le descripteur "video_pid" déjà existant
et d'indiquer le type de celui-ci à l'aide d'une variable spécifique.
Reconnaissance de la présence des flux audio "Extended AC3" (en attendant de
pouvoir les décoder).
Factorisations dans graph.cpp, notamment par l'ajout des fonctions
"connect_pin_to_filter" et "get_and_add_codec".
Utilisations de fonctions distinctes pour lancer et stopper le graphe (dans l'idée
plus ou moins expérimentale de limiter les ressources - ici 'pControl'
(IMediaControl) devenant locale et d'usage éphémère - réservées en permanence).
Ajout d'un certain nombre de tests d'erreur en mode debugging.
Mémorisation de l'état "suspendu" de l'audio et de la vidéo afin qu'un
changement de chaîne en mode suspendu n'ait pas pour effet de "désuspendre"
les sorties de ces modes.
Ajout d'un paramètre à la fonction "rebranche" indiquant si le rebranchement
doit être associé ou non à une réinitialisation du choix de la piste
son selon la préférence de configuration AC3. Une partie du contenu de
cette fonction est par ailleurs déplacée en tant que fonction membre
de la classe "Chaine". Des fonctions "branche_son" et "debranche_son"
sont également créées pour mieux en gérer cet aspect.
La fonction "debranche_tout" est renommée "debranche_tous_pids" ce qui
correspond mieux à son rôle réel.
Le branchement initial des flux au lancement est réorganisé de façon à ce
qu'un lancement en mode minimisé ne produise pas un branchement suivi d'un
débranchement immédiat (on se contente de ne rien brancher du tout ...).
La fonction "InitDshow" est supprimée (son contenu est déplacé directement
à son ancien point d'appel) : les deux actions majeures qu'elle effectuait
n'avaient pas de raison majeure d'être liés ensemble, et il est plus aisé
ainsi d'envisager de les dissocier.
Correction d'un bug dans l'EPG qui faisait que la demande d'enregistrement
d'une chaîne ne fonctionnait pas si le bouton "Enregistré" était pressé
sans que la sélection initiale ait été modifiée.
Quelques ajustements de types de variables (essentiellement pour éviter des
avertissements en mode 64 bits).
Modifié: trunk/Pouchin TV.vcproj
===================================================================
--- trunk/Pouchin TV.vcproj 2008-11-16 14:59:52 UTC (rev 140)
+++ trunk/Pouchin TV.vcproj 2008-11-20 12:15:06 UTC (rev 141)
@@ -137,6 +137,7 @@
UsePrecompiledHeader="0"
WarningLevel="4"
DebugInformationFormat="3"
+ DisableSpecificWarnings="4480"
/>
+ #include
#endif
#include "resource.h"
Modifié: trunk/capture.cpp
===================================================================
--- trunk/capture.cpp 2008-11-16 14:59:52 UTC (rev 140)
+++ trunk/capture.cpp 2008-11-20 12:15:06 UTC (rev 141)
@@ -68,7 +68,7 @@
}
CCapture_TS::CCapture_TS(
- HANDLE hFil, int pmt, int video,
+ HANDLE hFil, UINT16 pmt, UINT16 video,
const liste_pistes & lst_sons,
const liste_pistes & lst_autr) :
CCapture(hFil),
@@ -115,34 +115,34 @@
// Ajout d'un bloc "Pack Header" :
// (retourne la taille du bloc ajouté, ou bien 0 si échec)
- size_t addPackHeader();
+ UINT32 addPackHeader();
// Ajout d'un bloc "System Header" :
// (retourne la taille du bloc ajouté, ou bien 0 si échec)
- size_t addSystemHeader();
+ UINT32 addSystemHeader();
// Ajout d'un bloc PES de base, dérivé du bloc source 'p_src_hdr' :
// (retourne la taille du bloc ajouté, ou bien 0 si échec)
- size_t addPES_Header(IF_DEBUG(LPCSTR nom_debug));
+ UINT32 addPES_Header(IF_DEBUG(LPCSTR nom_debug));
// Ajout d'un bloc PES d'extension, dérivé du bloc source 'p_src_hdr' :
// (retourne la taille du bloc ajouté, ou bien 0 si échec)
- size_t addPES_extHeader();
+ UINT32 addPES_extHeader();
// Compléter le bloc avec un PES de padding, en laissant néanmoins
// éventuellement un espace de taille égale = 'guard' à la fin.
// Si l'ajustement requis est très faible, alors l'ajustement se fera, à la place,
// en ajoutant des octets de "stuffing" dans l'en-tête.
// Retourne la quantité de données *ajoutées* au buffer :
- size_t add_Padding(size_t guard=0);
+ UINT32 add_Padding(size_t guard=0);
// Ajout de données dans le bloc. Retourne 'true' si la totalité des données ont pu être ajoutées,
// 'false' sinon ; dans ce dernier cas, rien n'est modifié.
- bool addData(const UINT8 * ptr, size_t size);
+ bool addData(const UINT8 * ptr, UINT32 size);
// Ajout de données dans le bloc. Retourne 'true' si la totalité des données ont pu être ajoutées,
// 'false' sinon ; dans ce dernier cas, 'ptr' et 'size' sont ajustés sur les données restantes.
- bool addPES_data(const UINT8 * & ptr, size_t & size);
+ bool addPES_data(const UINT8 * & ptr, UINT32 & size);
// Ajustement de l'index du buffer pour que les données subséquentes s'inscrivent
// à partir de l'adresse 'ptr' :
@@ -154,7 +154,7 @@
// sont ajoutées.
// La fonction retourne le nombre d'octets *ajoutés* (en-têtes, remplissage, etc) par rapport au flot
// d'origine.
- size_t build(bool start, const UINT8 * & ptr, size_t & size IF_DEBUG_CB(LPCSTR nom_debug));
+ UINT32 build(bool start, const UINT8 * & ptr, UINT32 & size IF_DEBUG_CB(LPCSTR nom_debug));
// Vidange du tampon dans le fichier :
void write_to_file();
@@ -172,9 +172,9 @@
// sont ajoutées.
// La fonction retourne le nombre d'octets *ajoutés* (en-têtes, remplissage, etc) par rapport au flot
// d'origine.
-size_t PS_chunk::build(bool start, const UINT8 * & ptr, size_t & size IF_DEBUG_CB(LPCSTR nom_debug))
+UINT32 PS_chunk::build(bool start, const UINT8 * & ptr, UINT32 & size IF_DEBUG_CB(LPCSTR nom_debug))
{
- size_t added_bytes = 0;
+ UINT32 added_bytes = 0;
if (start) {
added_bytes += addPackHeader();
@@ -183,7 +183,7 @@
cGrabber.sys_header_set = true;
}
//
- size_t hdsize = addPES_Header(IF_DEBUG(nom_debug));
+ UINT32 hdsize = addPES_Header(IF_DEBUG(nom_debug));
// Le premier en-tête existait dans le tampon source, on le saute donc en lecture
ptr += hdsize;
size -= hdsize;
@@ -204,7 +204,7 @@
// Ajout de données dans le bloc. Retourne 'true' si la totalité des données ont pu être ajoutées,
// 'false' sinon ; dans ce dernier cas, rien n'est modifié.
-bool PS_chunk::addData(const UINT8 * ptr, size_t size)
+bool PS_chunk::addData(const UINT8 * ptr, UINT32 size)
{
if (ixBuf+size <= _countof(buffer)) {
memcpy(&buffer[ixBuf], ptr, size);
@@ -216,7 +216,7 @@
// Ajout de données dans le bloc. Retourne 'true' si la totalité des données ont pu être ajoutées,
// 'false' sinon ; dans ce dernier cas, 'ptr' et 'size' sont ajustés sur les données restantes.
-bool PS_chunk::addPES_data(const UINT8 * & ptr, size_t & size)
+bool PS_chunk::addPES_data(const UINT8 * & ptr, UINT32 & size)
{
UINT32 adjustedSize = UINT32(size);
bool fit = ixBuf+size <= _countof(buffer);
@@ -234,7 +234,7 @@
}
// Ajout d'un bloc "Pack header" :
-size_t PS_chunk::addPackHeader()
+UINT32 PS_chunk::addPackHeader()
{
if (sizeof(PS_chunk)-ixBuf >= sizeof(PS_PackHeader)) {
PS_PackHeader & phdr = *new(&buffer[ixBuf])PS_PackHeader(); // "Placement" new
@@ -250,7 +250,7 @@
}
// Ajout d'un bloc "System Header" :
-size_t PS_chunk::addSystemHeader()
+UINT32 PS_chunk::addSystemHeader()
{
if (sizeof(PS_chunk)-ixBuf >= sizeof(PS_SystemHeader)+2*sizeof(PS_SH_entry)) {
PS_SystemHeader & shd = *new (&buffer[ixBuf])PS_SystemHeader(); // "Placement" new
@@ -273,7 +273,7 @@
// Ajout d'un bloc PES de base, dérivé du bloc source 'p_src_hdr' :
// (retourne la taille du bloc ajouté, ou bien 0 si échec)
-size_t PS_chunk::addPES_Header(IF_DEBUG(LPCSTR nom_debug))
+UINT32 PS_chunk::addPES_Header(IF_DEBUG(LPCSTR nom_debug))
{
if (sizeof(PS_chunk)-ixBuf >= sizeof(PS_hdr_wd)) {
PS_hdr_wd & dst_hdr = *new (&buffer[ixBuf]) PS_hdr_wd(src_hdr); // "Placement" new
@@ -309,7 +309,7 @@
}
// Ajout d'un bloc PES d'extension, dérivé du bloc source 'p_src_hdr' :
-size_t PS_chunk::addPES_extHeader()
+UINT32 PS_chunk::addPES_extHeader()
{
if (sizeof(PS_chunk)-ixBuf >= sizeof(PS_hdr_wd)) {
PS_hdr_wd & dst_hdr = *new (&buffer[ixBuf])PS_hdr_wd(src_hdr); // "Placement" new
@@ -328,7 +328,7 @@
// Compléter le bloc avec un PES de padding, en laissant néanmoins
// éventuellement un espace de taille égale = 'guard' à la fin.
// Retourne la quantité de données *ajoutées* au buffer.
-size_t PS_chunk::add_Padding(size_t guard)
+UINT32 PS_chunk::add_Padding(size_t guard)
{
UINT16 remain = UINT16(sizeof(buffer)-guard-ixBuf);
@@ -361,7 +361,7 @@
// ************************************************************
-PS_buffer::PS_buffer(int used_pid, UINT8 maxChnk IF_DEBUG_CB(LPCSTR nom_dbg)) :
+PS_buffer::PS_buffer(UINT16 used_pid, UINT8 maxChnk IF_DEBUG_CB(LPCSTR nom_dbg)) :
pcGrab(NULL),
IF_DEBUG_CA(nom_debug(nom_dbg))
pid(used_pid),
@@ -406,7 +406,7 @@
if (valid && uw_th.p_payload) {
// Paquet valide et "Payload" présent
- size_t ptr_size = &p.bytes[TS_SIZE]-uw_th.p_payload;
+ UINT32 ptr_size = UINT32(&p.bytes[TS_SIZE]-uw_th.p_payload);
pcGrab->byte_count += ptr_size;
put_data(uw_th.p_payload, ptr_size, new_PES_starts_here);
@@ -416,10 +416,10 @@
void PS_buffer::send()
{
const UINT8 * ptr = data_ptr();
- size_t size = data_size;
+ UINT32 size = data_size;
const PS_hdr_wd & hdr = *reinterpret_cast(ptr);
bool start = true;
- size_t added_bytes = 0;
+ UINT32 added_bytes = 0;
while (size>0) {
PS_chunk chunk(hdr, *this);
@@ -432,7 +432,7 @@
pcGrab->byte_count += added_bytes;
}
-CCapture_PS::CCapture_PS(HANDLE hFil, int video, int audio) :
+CCapture_PS::CCapture_PS(HANDLE hFil, UINT16 video, UINT16 audio) :
CCapture(hFil),
first_pcr(0),
curr_pcr(0),
Modifié: trunk/capture.h
===================================================================
--- trunk/capture.h 2008-11-16 14:59:52 UTC (rev 140)
+++ trunk/capture.h 2008-11-20 12:15:06 UTC (rev 141)
@@ -56,14 +56,14 @@
class CCapture_TS : public CCapture
{
- int video_pid;
- int pmt_pid;
+ UINT16 video_pid;
+ UINT16 pmt_pid;
liste_pistes sons;
liste_pistes autr;
public:
- CCapture_TS(HANDLE hFil, int pmt, int video,
+ CCapture_TS(HANDLE hFil, UINT16 pmt, UINT16 video,
const liste_pistes & lst_sons,
const liste_pistes & lst_autr);
@@ -77,12 +77,12 @@
CCapture_PS * pcGrab;
IF_DEBUG(LPCSTR nom_debug;)
- int pid;
+ UINT16 pid;
bool valid;
UINT8 continuity_counter;
public:
- PS_buffer(int used_pid, UINT8 maxChnk IF_DEBUG_CB(LPCSTR nom_dbg));
+ PS_buffer(UINT16 used_pid, UINT8 maxChnk IF_DEBUG_CB(LPCSTR nom_dbg));
void traite_paquet(const TS_packet & p);
@@ -116,7 +116,7 @@
UINT32 curr_pcr_second; // Seconde entière du PCR courant (pour tests statistiques)
UINT32 pck_pcr_count; // Comptage des paquets "TS" depuis le dernier PCR reçu
UINT32 pcr_rate; // Taux d'incrémentation du PCR par paquet
- size_t byte_count; // Comptage des octets émis en mode PS pour calcul "multiplex rate"
+ UINT32 byte_count; // Comptage des octets émis en mode PS pour calcul "multiplex rate"
UINT32 byte_mux_rate; // "multiplex rate" courant, calculé en octets par seconde
RateHelper pcr_rate_helper; // assistance au calcul de l'intervalle de temps moyen entre paquets TS
RateHelper mux_rate_helper; // assistance au calcul du "multiplex rate"
@@ -126,7 +126,7 @@
PS_buffer audio_build;
public:
- CCapture_PS(HANDLE hFil, int video, int audio);
+ CCapture_PS(HANDLE hFil, UINT16 video, UINT16 audio);
virtual void traite_paquet(const TS_packet & p);
Modifié: trunk/channels.cpp
===================================================================
--- trunk/channels.cpp 2008-11-16 14:59:52 UTC (rev 140)
+++ trunk/channels.cpp 2008-11-20 12:15:06 UTC (rev 141)
@@ -36,6 +36,7 @@
int ixChaineCourante = -1;
int ixSonCourant = 0;
long volumeCourant = 0;
+bool suspendu = true; // 'true' si vidéo et audio suspendus (à l'initialisation, ou si minimisé + 'suspend_minimized')
// Taille des images des chaines (largeur et longueur)
#define TAILLE_IMAGE_CHAINE 16
@@ -63,32 +64,88 @@
ChainePMT::ChainePMT() :
video_pid(0),
- mpeg4_pid(0),
+ video_type(vst_Unknown),
pcr_pid(0)
{
}
bool ChainePMT::operator == (const ChainePMT & cpmt) const
{
- if (video_pid!=cpmt.video_pid || mpeg4_pid!=cpmt.mpeg4_pid || pcr_pid!=cpmt.pcr_pid)
+ if (video_pid!=cpmt.video_pid || video_type!=cpmt.video_type || pcr_pid!=cpmt.pcr_pid)
return false;
return sons==cpmt.sons && autr==cpmt.autr;
}
char ChainePMT::norme(void) const
{
- return video_pid!=0 ?
- (mpeg4_pid!=0 ? 'X': '2') :
- (mpeg4_pid!=0 ? '4': '?');
+ switch (video_type) {
+ case vst_MPEG2:
+ return '2';
+ case vst_H264:
+ case vst_H264_encrypted:
+ return '4';
+ }
+ return '?';
}
// Constructeur :
-Chaine::Chaine()
+Chaine::Chaine() :
+ canal_no(0),
+ pmt_pid(0),
+ frequence(0),
+ etat(ec_preferee),
+ numeroChaine(0),
+ emi_count(0),
+ hImage(NULL)
{
- memset(this, 0, sizeof(*this));
- etat=ec_preferee;
+ nom[0] = 0;
+ groupe[0] = 0;
}
+static void branche_son(une_piste son)
+{
+ ULONG pid = son.pid;
+ HRESULT hr;
+
+ if (pid!=0) {
+ switch (son.type) {
+
+ case ast_MPEG2:
+ hr = pMapSound->MapPID(1, &pid, MEDIA_ELEMENTARY_STREAM);
+ myprintf(L"%?erreur pid son, hr=0x%08x\n", FAILED(hr), hr);
+ break;
+
+ case ast_AC3:
+ hr = pMapAc3->MapPID(1, &pid, MEDIA_ELEMENTARY_STREAM);
+ myprintf(L"%?erreur pid ac3, hr=0x%08x\n", FAILED(hr), hr);
+ break;
+
+ default:
+ myprintf(L"Type de piste audio non identifié\n");
+ }
+ }
+}
+
+static void debranche_son(une_piste son)
+{
+ ULONG pid = son.pid;
+
+ if (pid!=0)
+ switch (son.type) {
+
+ case ast_MPEG2:
+ pMapSound->UnmapPID(1, &pid);
+ break;
+
+ case ast_AC3:
+ pMapAc3->UnmapPID(1, &pid);
+ break;
+
+ default:
+ myprintf(L"Type de piste audio non identifié\n");
+ }
+}
+
HBITMAP Chaine::ChargeIcone()
{
if (hImage==INVALID_HANDLE_VALUE)
@@ -125,6 +182,50 @@
return swprintf_s(pstr, bufSize, L"%4i : %S", numeroChaine, nom);
}
+// Mappage de tous les PIDs de la chaîne (la fréquence est présumée déjà syntonisée) ;
+// Si 'reset_son' est 'true', alors le canal son est, en même temps, remis à sa
+// valeur par défaut, selon préférences globales de l'utilisateur :
+HRESULT Chaine::branche(bool reset_son) const
+{
+ myprintf(L"SID %i, TSID %i, ONID %i, freq : %i\n", SID, TSID, ONID, frequence);
+
+ ULONG pid = video_pid;
+ HRESULT hr = E_FAIL; // valeur par défaut
+
+ if (pid) {
+ switch (video_type) {
+ case vst_MPEG2:
+ if (pMapMPEG2)
+ hr = pMapMPEG2->MapPID(1, &pid, MEDIA_ELEMENTARY_STREAM);
+ break;
+ default:
+ hr=E_FAIL;
+ }
+ myprintf(L"%?erreur pid video, hr=0x%08x\n", FAILED(hr), hr);
+ }
+
+ if (reset_son) {
+ ixSonCourant = 0; // par défaut
+
+ if (use_ac3) { // AC3 par défaut : chercher s'il y a une piste AC3
+ for (int i=0; iMapPID(1, &pid, MEDIA_MPEG2_PSI);
+ myprintf(L"%?erreur pid pmt, hr=0x%08x\n", FAILED(hr), hr);
+ return hr;
+}
+
/**
* Recherche de l'index correspondant à un numéro de chaîne 'numChaine'.
* Retourne -1 si pas trouvé.
@@ -265,7 +366,9 @@
return true;
}
-static void debranche_tout(CComPtr & pMap)
+// Débranchement de tous les flux élémentaires (identifiés par PID) qui sont couramment
+// présentés sur la connexion pMap.
+static void debranche_tous_pids(CComPtr & pMap IF_DEBUG_CB(LPCSTR nom_itf))
{
PID_MAP maps[8];
ULONG nbPids;
@@ -277,135 +380,107 @@
pEnumMap->Next(_countof(maps), maps, &nbPids);
}
+ myprintf(L"debranche %u pid(s) sur pMap=%S\n", nbPids, nom_itf);
for (ULONG i=0; iUnmapPID(1, &maps[i].ulPID);
myprintf(L"%?unmap foiré, hr=0x%08x\n", FAILED(hr), hr);
}
}
+// Déconnexion globale des sorties vidéo et audio :
void debranche()
-{ // (noms de fonctions à revoir ??)
- debranche_tout(pMapMPEG2);
- debranche_tout(pMapSound);
- debranche_tout(pMapAc3);
- debranche_tout(pMapPmt);
+{
+ if (!suspendu) {
+ debranche_tous_pids(pMapMPEG2 IF_DEBUG_CB("pMapMPEG2"));
+ debranche_tous_pids(pMapSound IF_DEBUG_CB("pMapSound"));
+ debranche_tous_pids(pMapAc3 IF_DEBUG_CB("pMapAc3"));
+ debranche_tous_pids(pMapPmt IF_DEBUG_CB("pMapPmt"));
+
+ suspendu = true;
+ }
}
-void switch_audio(int old_son, int new_son)
+// Reconnexion globale des sorties vidéo et audio ;
+// si 'reset_son' est 'true', alors le canal son est, en même temps, remis à sa
+// valeur par défaut, selon les préférences globales de l'utilisateur :
+bool rebranche(bool reset_son)
{
- const une_piste * son_courant = Canaux[ixChaineCourante].sons.tbl;
- ULONG old_pid = son_courant[old_son].pid;
- ULONG new_pid = son_courant[new_son].pid;
+ // Note : l'initialisation du VMR est en principe ici déjà faite (ce qui fait
+ // que cet appel sera sans doute sans effet), mais ceci réserve la possibilité
+ // de retarder cet appel jusqu'au 1er branchement des flux .... le jour où
+ // j'aurai trouvé pourquoi cela pose problème ! - Gingko
+ if (do_init_vmr()) {
- int old_type = son_courant[old_son].type;
- int new_type = son_courant[new_son].type;
-
- if (old_type==1) {
- pMapAc3->UnmapPID(1, &old_pid);
- } else {
- pMapSound->UnmapPID(1, &old_pid);
+ if (suspendu) {
+ suspendu = false;
+ Canaux[ixChaineCourante].branche(reset_son);
+ }
+ return true;
}
+ return false;
+}
- if (new_type==1) {
- pMapAc3->MapPID(1, &new_pid, MEDIA_ELEMENTARY_STREAM);
- } else {
- pMapSound->MapPID(1, &new_pid, MEDIA_ELEMENTARY_STREAM);
+void switch_audio(int new_son)
+{
+ if (new_son != ixSonCourant) {
+ const une_piste * son_courant = Canaux[ixChaineCourante].sons.tbl;
+
+ debranche_son(son_courant[ixSonCourant]);
+ branche_son(son_courant[new_son]);
+
+ ixSonCourant=new_son;
}
-
- ixSonCourant=new_son;
}
// Changement de chaîne pour la chaîne dont l'index est donné en paramètre.
// Retourne 0 si pas d'erreur, 1 si le changement n'a pas pu avoir lieu
-int change_chaine(int ixChaine)
+// (mettre -1 pour désactiver la sélection de chaîne)
+HRESULT change_chaine(int ixChaine)
{
- bool freq_differente = true;
+ bool freq_differente = true;
+ bool sauve_suspend = suspendu;
+ bool reset_son = ixChaine!=ixChaineCourante;
+
if (ixChaine_ok(ixChaineCourante) && ixChaine_ok(ixChaine) &&
- Canaux[ixChaineCourante].frequence == Canaux[ixChaine].frequence)
+ Canaux[ixChaineCourante].frequence == Canaux[ixChaine].frequence &&
+ Canaux[ixChaineCourante].video_type == Canaux[ixChaine].video_type)
{
freq_differente = false;
}
if (freq_differente && recording())
- return 1; // On ne change pas de fréquence si enregistrement en cours
+ return S_FALSE; // On ne change pas de fréquence si enregistrement en cours
ixChaineCourante = -1; // doit être égal à -1 pendant les transitions (à cause du filtre PMT)
- debranche();
+ if (!suspendu) {
+ debranche();
+ }
if (ixChaine >= 0) {
+ myprintf(L"zappe %i\n", ixChaine+1);
+
const Chaine & nouveau_canal = Canaux[ixChaine];
- myprintf(L"zappe %i\n", ixChaine+1);
- myprintf(L"SID %i, TSID %i, ONID %i, freq : %i\n", nouveau_canal.SID, nouveau_canal.TSID, nouveau_canal.ONID, nouveau_canal.frequence);
-
if (freq_differente)
change_frequence(nouveau_canal.frequence);
- ULONG pid = nouveau_canal.video_pid;
- HRESULT hr;
+ ixChaineCourante = ixChaine_ok(ixChaine) ? ixChaine : -1;
- if (pid) {
- hr = pMapMPEG2->MapPID(1, &pid, MEDIA_ELEMENTARY_STREAM);
- myprintf(L"%?erreur pid video, hr=0x%08x\n", FAILED(hr), hr);
- }
+ // Ne reconnecter l'interface que si elle l'était avant :
+ if (!sauve_suspend)
+ rebranche(reset_son);
+ } else {
+ // ixChaine < 0 pour désélection de chaîne
- int piste_ac3=-1;
-
- for (int i=0; iMapPID(1, &pid, MEDIA_ELEMENTARY_STREAM);
- myprintf(L"%?erreur pid ac3, hr=0x%08x\n", FAILED(hr), hr);
- }
- } else { // passe en MPEG audio
- pid = nouveau_canal.sons.tbl[0].pid;
- if (pid) {
- hr = pMapSound->MapPID(1, &pid, MEDIA_ELEMENTARY_STREAM);
- ixSonCourant=0;
- myprintf(L"%?erreur pid son, hr=0x%08x\n", FAILED(hr), hr);
- }
- }
-
- // pmt
-
- pid = nouveau_canal.pmt_pid;
- hr = pMapPmt->MapPID(1, &pid, MEDIA_MPEG2_PSI);
- myprintf(L"%?erreur pid pmt, hr=0x%08x\n", FAILED(hr), hr);
-
+ // Restaurer 'suspendu' après désélection de chaîne sinon l'affichage
+ // ne redémarre pas à l'issue d'une recherche de chaînes :
+ suspendu = sauve_suspend;
}
- ixChaineCourante = ixChaine_ok(ixChaine) ? ixChaine : -1;
-
- return 0;
+ return S_OK;
}
-void rebranche()
-{
- const Chaine & canal_courant = Canaux[ixChaineCourante];
- HRESULT hr;
-
- ULONG pid = canal_courant.video_pid;
- hr = pMapMPEG2->MapPID(1, &pid, MEDIA_ELEMENTARY_STREAM);
- myprintf(L"%?erreur pid video, hr=0x%08x\n", FAILED(hr), hr);
-
- pid = canal_courant.sons.tbl[ixSonCourant].pid;
- if (canal_courant.sons.tbl[ixSonCourant].type == 1) {
- hr = pMapAc3->MapPID(1, &pid, MEDIA_ELEMENTARY_STREAM);
- myprintf(L"%?erreur pid ac3, hr=0x%08x\n", FAILED(hr), hr);
- } else {
- hr = pMapSound->MapPID(1, &pid, MEDIA_ELEMENTARY_STREAM);
- myprintf(L"%?erreur pid son, hr=0x%08x\n", FAILED(hr), hr);
- }
-}
-
void set_volume(long volume)
{
CComQIPtr pBas(pGraph);
Modifié: trunk/channels.h
===================================================================
--- trunk/channels.h 2008-11-16 14:59:52 UTC (rev 140)
+++ trunk/channels.h 2008-11-20 12:15:06 UTC (rev 141)
@@ -36,11 +36,14 @@
SYSTEMTIME fin;
char nom[86];
char desc[256];
+
+ Emission() {
+ ZeroMemory(this, sizeof(*this));}
};
struct ChainePMT {
UINT16 video_pid;
- UINT16 mpeg4_pid;
+ VideoStreamType video_type;
UINT16 pcr_pid;
liste_pistes sons;
liste_pistes autr;
@@ -57,6 +60,13 @@
UINT16 TSID;
UINT16 SID;
UINT16 numero_nit;// Numéro de chaîne original
+
+ ChaineIDs() :
+ ONID(0),
+ TSID(0),
+ SID(0),
+ numero_nit(0)
+ {}
};
enum EtatChaine {
@@ -92,14 +102,20 @@
(numeroChaine == canal2.numeroChaine && _stricmp(nom, canal2.nom) > 0); }
// Génération du nom affichable pour le menu
int toMenuString(LPWSTR pstr, size_t bufSize) const;
+
+ // Mappage de tous les PIDs de la chaîne (la fréquence est présumée déjà syntonisée) ;
+ // Si 'reset_son' est 'true', alors le canal son est, en même temps, remis à sa
+ // valeur par défaut, selon préférences globales de l'utilisateur :
+ HRESULT branche(bool reset_son) const;
};
// Tableau des chaînes
extern std::vector Canaux;
-extern int ixChaineCourante; // Index de la chaîne couramment utilisée
-extern int ixSonCourant; // Index de la piste sonore couramment utilisée
+extern int ixChaineCourante; // Index de la chaîne couramment utilisée
+extern int ixSonCourant; // Index de la piste sonore couramment utilisée
extern long volumeCourant; // Niveau de volume sonore courant
+extern bool suspendu; // 'true' si vidéo et audio suspendus (à l'initialisation, ou si minimisé + 'suspend_minimized')
void change_frequence(ULONG freq);
@@ -107,17 +123,23 @@
// Changement de chaîne pour la chaîne dont l'index est donné en paramètre.
// Retourne 0 si pas d'erreur, 1 si le changement n'a pas pu avoir lieu
-int change_chaine(int ixChaine);
+// (mettre -1 pour désactiver la sélection de chaîne)
+HRESULT change_chaine(int ixChaine);
// Changement de piste son :
-void switch_audio(int old_son, int new_son);
+void switch_audio(int new_son);
// Changement de volume sonore :
void set_volume(long volume);
+// Déconnexion globale des sorties vidéo et audio :
void debranche();
-void rebranche();
+// Reconnexion globale des sorties vidéo et audio ;
+// si 'reset_son' est 'true', alors le canal son est, en même temps, remis à sa
+// valeur par défaut, selon les préférences globales de l'utilisateur :
+bool rebranche(bool reset_son);
+
/**
* Recherche de l'index correspondant à un numéro de chaîne 'numChaine'.
* Retourne -1 si pas trouvé.
Modifié: trunk/chanutils.cpp
===================================================================
--- trunk/chanutils.cpp 2008-11-16 14:59:52 UTC (rev 140)
+++ trunk/chanutils.cpp 2008-11-20 12:15:06 UTC (rev 141)
@@ -61,7 +61,7 @@
return false;
}
-int liste_pistes::ajoute(UINT16 newpid, UINT8 newtype, LPCSTR newlang)
+int liste_pistes::ajoute(UINT16 newpid, AudioStreamType newtype, LPCSTR newlang)
{
if (nbr<_countof(tbl)) {
une_piste & piste = tbl[nbr];
Modifié: trunk/chanutils.h
===================================================================
--- trunk/chanutils.h 2008-11-16 14:59:52 UTC (rev 140)
+++ trunk/chanutils.h 2008-11-20 12:15:06 UTC (rev 141)
@@ -39,16 +39,32 @@
#include
+enum VideoStreamType : UINT8
+{
+ vst_Unknown = 0xff,
+ vst_MPEG2 = 0,
+ vst_H264,
+ vst_H264_encrypted // -> va sans doute être utilisé prochainement
+};
+
+enum AudioStreamType : UINT8
+{
+ ast_Unknown = 0xff,
+ ast_MPEG2 = 0, // 0 = MPEG2 Audio Layer II
+ ast_AC3, // 1 = AC3
+ ast_EAC3 // 2 = Extended AC3
+};
+
// Nombre max de pistes son par chaîne
#define NB_MAX_PISTES 32
struct une_piste {
- UINT16 pid;
- UINT8 type; // si son : 0 = normal, 1 = AC3; réservé si autres
- char lang[8];
+ UINT16 pid;
+ AudioStreamType type; // si son : voir AudioStreamType; ast_Unknown (réservé) si autres
+ char lang[8];
// Efface le tableau de caractère, car pose des problèmes des fois si pas effacé
- une_piste() : pid(0), type(0) {ZeroMemory(lang, sizeof(lang)); };
+ une_piste() : pid(0), type(ast_Unknown) {ZeroMemory(lang, sizeof(lang)); };
une_piste(const une_piste &piste);
bool operator == (const une_piste & up) const
@@ -59,13 +75,13 @@
};
struct liste_pistes {
- UINT16 nbr;
- une_piste tbl[NB_MAX_PISTES];
+ UINT16 nbr;
+ une_piste tbl[NB_MAX_PISTES];
liste_pistes() : nbr(0) {};
bool cherche_pid(UINT16 pid) const;
- int ajoute(UINT16 newpid, UINT8 newtype=0, LPCSTR newlang=NULL);
+ int ajoute(UINT16 newpid, AudioStreamType newtype, LPCSTR newlang=NULL);
bool operator == (const liste_pistes & lp) const;
bool operator != (const liste_pistes & lp) const {return ! operator == (lp);};
};
Modifié: trunk/epg.cpp
===================================================================
--- trunk/epg.cpp 2008-11-16 14:59:52 UTC (rev 140)
+++ trunk/epg.cpp 2008-11-20 12:15:06 UTC (rev 141)
@@ -98,6 +98,7 @@
if (visible_index >= 0) {
ListView_SetItemState(hListItem, visible_index, LVIS_SELECTED, LVIS_SELECTED);
+ ListView_SetSelectionMark(hListItem, visible_index);
ListView_EnsureVisible(hListItem, visible_index, FALSE);
}
}
@@ -177,18 +178,20 @@
// le reste à zéro (implicite)
};
- ListView_GetItem(hListItem, &item);
+ if (ListView_GetItem(hListItem, &item)) {
+ int ixChaine = trouve_chaine_par_sid(LOWORD(item.lParam));
+ Programme prog;
- int ixChaine = trouve_chaine_par_sid(LOWORD(item.lParam));
- Programme prog;
+ if (!chaineToProg(ixChaine, LOBYTE(HIWORD(item.lParam)), prog) || !prog.verifie(false))
+ return FALSE;
+ prog.methode = (MethodeEnregistrement)SendDlgItemMessage(hDlg, IDC_METHOD_EPG, CB_GETCURSEL, 0, 0);
+ prog.audio = (AudioMode)SendDlgItemMessage(hDlg, IDC_AUDIO_EPG, CB_GETCURSEL, 0, 0);
- if (!chaineToProg(ixChaine, LOBYTE(HIWORD(item.lParam)), prog) || !prog.verifie(false))
- return FALSE;
- prog.methode = (MethodeEnregistrement)SendDlgItemMessage(hDlg, IDC_METHOD_EPG, CB_GETCURSEL, 0, 0);
- prog.audio = (AudioMode)SendDlgItemMessage(hDlg, IDC_AUDIO_EPG, CB_GETCURSEL, 0, 0);
+ Programmes.push_back(prog);
+ finalize_prog_change();
+ } else
+ affiche_erreurs(L"Item non sélectionné");
- Programmes.push_back(prog);
- finalize_prog_change();
return TRUE; }
}
return FALSE;
Modifié: trunk/graph.cpp
===================================================================
--- trunk/graph.cpp 2008-11-16 14:59:52 UTC (rev 140)
+++ trunk/graph.cpp 2008-11-20 12:15:06 UTC (rev 141)
@@ -38,7 +38,6 @@
#include
CComPtr pGraph;
-CComPtr pControl;
CComPtr pVMRControl;
@@ -82,7 +81,7 @@
if (FAILED(GetRunningObjectTable(0, &pROT)))
return E_FAIL;
- StringCchPrintfW(wsz, _countof(wsz), L"FilterGraph %08x pid %08x", (DWORD_PTR)&pGraph.p, GetCurrentProcessId());
+ swprintf_s(wsz, L"FilterGraph %08x pid %08x", (DWORD_PTR)&pGraph.p, GetCurrentProcessId());
HRESULT hr = CreateItemMoniker(L"!", wsz, &pMoniker);
@@ -113,11 +112,8 @@
myprintf(L"callback ok\n");
- if (pControl) {
- pControl->Stop();
- }
+ graph_Stop();
-
myprintf(L"stop ok\n");
#if LOG_DSHOW
@@ -162,9 +158,10 @@
for (int i=0; i & pFilter)
{
@@ -181,21 +178,44 @@
return hr;
}
-static HRESULT connect_filters(CComPtr & source, CComPtr & dest)
+// Création et ajout d'un filtre de type codec défini par son nom, et devant
+// de plus correspondre au type 'type' et au sous-type 'subtype' définis.
+static HRESULT get_and_add_codec(LPCWSTR nom, GUID type, GUID subtype,
+ LPCWSTR infotype, CComPtr & pFilter)
{
- CComPtr pPin1;
- CComPtr pPin2;
- HRESULT hr = cherche_pin(source, PINDIR_OUTPUT, pPin1);
+ HRESULT hr = get_filter(type, subtype, nom, pFilter);
if (SUCCEEDED(hr)) {
- hr = cherche_pin(dest, PINDIR_INPUT, pPin2);
- if (SUCCEEDED(hr))
- hr = pGraph->ConnectDirect(pPin1, pPin2, NULL);
+ myprintf(L"Ajout codec %s\n", infotype);
+
+ hr = pGraph->AddFilter(pFilter, nom);
+ if (FAILED(hr))
+ return erreur(L"Le codec %s \"%s\" n'a pas pu être inséré dans le graphe",
+ hr, infotype, nom);
}
+ return hr;
+}
+static HRESULT connect_pin_to_filter(CComPtr & pOutPin, CComPtr & pFilter)
+{
+ CComPtr pInPin;
+ HRESULT hr = cherche_pin(pFilter, PINDIR_INPUT, pInPin);
+
+ if (SUCCEEDED(hr))
+ hr = pGraph->ConnectDirect(pOutPin, pInPin, NULL);
return hr;
}
+static HRESULT connect_filters(CComPtr & source, CComPtr & dest)
+{
+ CComPtr pOutPin;
+ HRESULT hr = cherche_pin(source, PINDIR_OUTPUT, pOutPin);
+
+ if (SUCCEEDED(hr))
+ hr = connect_pin_to_filter(pOutPin, dest);
+ return hr;
+}
+
static HRESULT getFrequencyFilter(CComPtr & pNetworkTuner)
{
HRESULT hr = pNetworkTuner.QueryInterface(&pBDAControl);
@@ -302,8 +322,6 @@
return S_OK;
}
- CComPtr pVideoPin;
-
AM_MEDIA_TYPE am;
am.majortype = MEDIATYPE_Video;
am.subtype = MEDIASUBTYPE_MPEG2_VIDEO;
@@ -335,26 +353,19 @@
mvi.hdr.bmiHeader.biWidth = 720;
mvi.hdr.bmiHeader.biHeight = 576;
+ CComPtr pVideoPin;
HRESULT hr = pMpeg2Demux->CreateOutputPin(&am, L"video", &pVideoPin);
+
if (FAILED(hr))
return erreur(L"La broche vidéo MPEG2 n'a pas pu être créée", hr);
// le décodeur vidéo
- hr = get_filter(MEDIATYPE_Video, MEDIASUBTYPE_MPEG2_VIDEO, filtreMPEG2, pVideoCodec);
- if (SUCCEEDED(hr)) {
- myprintf(L"Ajout video MPEG2\n");
+ hr = get_and_add_codec(filtreMPEG2, MEDIATYPE_Video, MEDIASUBTYPE_MPEG2_VIDEO,
+ L"vidéo MPEG2", pVideoCodec);
- hr = pGraph->AddFilter(pVideoCodec, filtreMPEG2);
+ if (SUCCEEDED(hr)) {
+ hr = connect_pin_to_filter(pVideoPin, pVideoCodec);
if (FAILED(hr))
- return erreur(L"Le codec vidéo MPEG2 \"%s\" n'a pas pu être inséré dans le graphe", hr, filtreMPEG2);
-
- CComPtr pPinEntree;
-
- hr = cherche_pin(pVideoCodec, PINDIR_INPUT, pPinEntree);
- if (SUCCEEDED(hr))
- hr = pGraph->ConnectDirect(pVideoPin, pPinEntree, NULL);
-
- if (FAILED(hr))
return erreur(L"Impossible de connecter le démultiplexeur au codec vidéo MPEG2 \"%s\"", hr, filtreMPEG2);
} else {
hr = pGraph->RenderEx(pVideoPin, AM_RENDEREX_RENDERTOEXISTINGRENDERERS, NULL);
@@ -362,18 +373,16 @@
return erreur(L"Pas de rendu possible depuis la broche vidéo MPEG2", hr);
}
- pVideoPin.QueryInterface(&pMapMPEG2);
+ hr = pVideoPin.QueryInterface(&pMapMPEG2);
+ myprintf(L"%?erreur pMapMPEG2, hr=0x%08x\n", FAILED(hr), hr);
return hr;
}
HRESULT init_vmr()
{
+ HRESULT hr = graph_Stop();
- pControl->Stop();
-
- HRESULT hr;
-
// crée le VMR
hr = create_and_add_filter(MyV(CLSID_VideoMixingRenderer), L"Video Mixing Renderer", pVMR);
@@ -429,8 +438,10 @@
return erreur(L"Échec de SetRenderingPrefs", hr);
}
- pNotify->AdviseSurfaceAllocator(0x118218, pSurfAlloc);
- pSurfAlloc->AdviseNotify(pNotify);
+ hr = pNotify->AdviseSurfaceAllocator(0x118218, pSurfAlloc);
+ myprintf(L"%?erreur AdviseSurfaceAllocator, hr=0x%08x\n", FAILED(hr), hr);
+ hr = pSurfAlloc->AdviseNotify(pNotify);
+ myprintf(L"%?erreur AdviseNotify, hr=0x%08x\n", FAILED(hr), hr);
}
if (use_vmr_deinterlace) {
@@ -498,10 +509,12 @@
return hr;
}
- pVMRControl->SetVideoClippingWindow(hMainWnd);
+ hr = pVMRControl->SetVideoClippingWindow(hMainWnd);
+ myprintf(L"%?erreur SetVideoClippingWindow, hr=0x%08x\n", FAILED(hr), hr);
#if !USE_VMR9
- pVMRControl->SetColorKey(colorKey);
+ hr = pVMRControl->SetColorKey(colorKey);
+ myprintf(L"%?erreur SetColorKey, hr=0x%08x\n", FAILED(hr), hr);
#endif
{
@@ -509,15 +522,16 @@
if (!pARC)
return erreur(L"L'interface de contrôle du ratio d'aspect n'est pas disponible", E_NOINTERFACE);
- pARC->SetAspectRatioMode(VMR_ARMODE_LETTER_BOX);
+ hr = pARC->SetAspectRatioMode(VMR_ARMODE_LETTER_BOX);
+ myprintf(L"%?erreur SetAspectRatioMode, hr=0x%08x\n", FAILED(hr), hr);
}
-
if (pVideoCodec != NULL) {
hr = connect_filters(pVideoCodec, pVMR);
if (FAILED(hr)) {
// Ici, on affiche l'erreur mais on ne quitte pas (ça laisse la possibilité d'enregistrer)
affiche_erreurs(L"Impossible de connecter le codec vidéo au VMR.\nC'est probablement l'overlay qui n'est pas disponible.\n\nVeuillez le libérer et relancer l'application", hr);
+ hr = S_OK;
}
} else {
@@ -525,15 +539,11 @@
return hr;
}
- hr = pControl->Run();
-
- return hr;
+ return graph_Run();
}
static HRESULT render_son(IMpeg2Demultiplexer * pMpeg2Demux)
{
- CComPtr pSoundPin;
-
AM_MEDIA_TYPE am;
am.majortype = MEDIATYPE_Audio;
am.subtype = MEDIASUBTYPE_MPEG2_AUDIO;
@@ -556,7 +566,9 @@
wfm.wBitsPerSample = 16;
wfm.cbSize = 0;
+ CComPtr pSoundPin;
HRESULT hr = pMpeg2Demux->CreateOutputPin(&am, L"son", &pSoundPin);
+
if (FAILED(hr))
return erreur(L"La broche audio MPEG2 n'a pas pu être créée", hr);
@@ -566,23 +578,11 @@
return hr;
// le décodeur audio
- hr = get_filter(MEDIATYPE_Audio, MEDIASUBTYPE_MPEG2_AUDIO, filtreAudio, pAudioCodec);
+ hr = get_and_add_codec(filtreAudio, MEDIATYPE_Audio, MEDIASUBTYPE_MPEG2_AUDIO,
+ L"audio MPEG2", pAudioCodec);
if (SUCCEEDED(hr)) {
-
- myprintf(L"ajout audio\n");
-
- hr = pGraph->AddFilter(pAudioCodec, filtreAudio);
-
+ hr = connect_pin_to_filter(pSoundPin, pAudioCodec);
if (FAILED(hr))
- return erreur(L"Le codec audio MPEG2 \"%s\" n'a pas pu être inséré dans le graphe", hr, filtreAudio);
-
- CComPtr pPinEntree;
-
- hr = cherche_pin(pAudioCodec, PINDIR_INPUT, pPinEntree);
- if (SUCCEEDED(hr))
- hr = pGraph->ConnectDirect(pSoundPin, pPinEntree, NULL);
-
- if (FAILED(hr))
return erreur(L"Impossible de connecter le démultiplexeur au codec audio MPEG2 \"%s\"", hr, filtreAudio);
hr = connect_filters(pAudioCodec, pDSound);
@@ -603,7 +603,6 @@
static HRESULT render_ac3(IMpeg2Demultiplexer * pMpeg2Demux)
{
- CComPtr pAc3Pin;
AM_MEDIA_TYPE am;
am.majortype = MEDIATYPE_Audio;
@@ -627,8 +626,9 @@
wfm.wBitsPerSample = 16;
wfm.cbSize = 0;
-
+ CComPtr pAc3Pin;
HRESULT hr = pMpeg2Demux->CreateOutputPin(&am, L"ac3", &pAc3Pin);
+
if (FAILED(hr))
return erreur(L"La broche audio AC3 n'a pas pu être créée", hr);
@@ -638,29 +638,16 @@
return hr;
// le décodeur ac3
- hr = get_filter(MEDIATYPE_Audio, MEDIASUBTYPE_DOLBY_AC3, filtreAc3, pAc3Codec);
+ hr = get_and_add_codec(filtreAc3, MEDIATYPE_Audio, MEDIASUBTYPE_DOLBY_AC3,
+ L"audio AC3", pAc3Codec);
if (SUCCEEDED(hr)) {
-
- myprintf(L"ajout ac3\n");
-
- hr = pGraph->AddFilter(pAc3Codec, filtreAc3);
-
+ hr = connect_pin_to_filter(pAc3Pin, pAc3Codec);
if (FAILED(hr))
- return erreur(L"Le codec audio AC3 \"%s\" n'a pas pu être inséré dans le graphe", hr, filtreAc3);
-
- CComPtr pPinEntree;
-
- hr = cherche_pin(pAc3Codec, PINDIR_INPUT, pPinEntree);
- if (SUCCEEDED(hr))
- hr = pGraph->ConnectDirect(pAc3Pin, pPinEntree, NULL);
-
- if (FAILED(hr))
return erreur(L"Impossible de connecter le démultiplexeur au codec AC3 \"%s\"", hr, filtreAc3);
hr = connect_filters(pAc3Codec, pDSoundAc3);
if (FAILED(hr))
return erreur(L"Impossible de connecter le Codec audio AC3 \"%s\" au filtre de rendu DirectSound", hr, filtreAc3);
-
} else {
hr = pGraph->RenderEx(pAc3Pin, AM_RENDEREX_RENDERTOEXISTINGRENDERERS, NULL);
if (FAILED(hr))
@@ -676,7 +663,6 @@
static HRESULT render_psi(IMpeg2Demultiplexer * pMpeg2Demux)
{
- CComPtr pDataPin;
AM_MEDIA_TYPE am;
am.majortype = MEDIATYPE_MPEG2_SECTIONS;
@@ -690,7 +676,9 @@
am.cbFormat = 0;
am.pbFormat = NULL;
+ CComPtr pDataPin;
HRESULT hr = pMpeg2Demux->CreateOutputPin(&am, L"data", &pDataPin);
+
if (FAILED(hr)) {
erreur(L"La broche PSI n'a pas pu être créée", hr);
return hr;
@@ -713,12 +701,7 @@
return hr;
}
- CComPtr pPinEntree;
-
- hr = cherche_pin(pPSIFilter, PINDIR_INPUT, pPinEntree);
- if (SUCCEEDED(hr))
- hr = pGraph->ConnectDirect(pDataPin, pPinEntree, NULL);
-
+ hr = connect_pin_to_filter(pDataPin, pPSIFilter);
if (FAILED(hr))
return erreur(L"Impossible de connecter le démultiplexeur au filtre PSI", hr);
}
@@ -728,7 +711,6 @@
static HRESULT render_epgfilter(IMpeg2Demultiplexer * pMpeg2Demux)
{
- CComPtr pEpgPin;
AM_MEDIA_TYPE am;
am.majortype = MEDIATYPE_MPEG2_SECTIONS;
@@ -742,7 +724,9 @@
am.cbFormat = 0;
am.pbFormat = NULL;
+ CComPtr pEpgPin;
HRESULT hr = pMpeg2Demux->CreateOutputPin(&am, L"epg", &pEpgPin);
+
if (FAILED(hr)) {
erreur(L"La broche EPG n'a pas pu être créée", hr);
return hr;
@@ -759,16 +743,9 @@
if (FAILED(hr))
return erreur(L"Le filtre EPG n'a pas pu être ajouté au graphe", hr);
- CComPtr pPinEntree;
-
- hr = cherche_pin(pEPGFilter, PINDIR_INPUT, pPinEntree);
+ hr = connect_pin_to_filter(pEpgPin, pEPGFilter);
if (FAILED(hr))
- return erreur(L"La broche d'entrée EPG n'a pas été trouvée", hr);
-
- hr = pGraph->ConnectDirect(pEpgPin, pPinEntree, NULL);
-
- if (FAILED(hr))
- return erreur(L"La broche d'entrée EPG n'a pas pu être connectée", hr);
+ return erreur(L"Impossible de connecter le démultiplexeur au filtre EPG", hr);
}
CComQIPtr pMapEpg(pEpgPin);
@@ -784,8 +761,6 @@
static HRESULT render_pmtfilter(IMpeg2Demultiplexer * pMpeg2Demux)
{
- CComPtr pPmtPin;
-
AM_MEDIA_TYPE am;
am.majortype = MEDIATYPE_MPEG2_SECTIONS;
am.subtype = MEDIASUBTYPE_DVB_SI;
@@ -798,6 +773,7 @@
am.cbFormat = 0;
am.pbFormat = NULL;
+ CComPtr pPmtPin;
HRESULT hr = pMpeg2Demux->CreateOutputPin(&am, L"pmt", &pPmtPin);
if (FAILED(hr))
@@ -815,17 +791,9 @@
if (FAILED(hr))
return erreur(L"Le filtre PMT n'a pas pu être ajouté au graphe", hr);
- CComPtr pPinEntree;
-
- hr = cherche_pin(pPMTFilter, PINDIR_INPUT, pPinEntree);
+ hr = connect_pin_to_filter(pPmtPin, pPMTFilter);
if (FAILED(hr))
- return erreur(L"La broche d'entrée PMT n'a pas été trouvée", hr);
-
- hr = pGraph->ConnectDirect(pPmtPin, pPinEntree, NULL);
-
- if (FAILED(hr))
- return erreur(L"La broche d'entrée PMT n'a pas pu être connectée", hr);
-
+ return erreur(L"Impossible de connecter le démultiplexeur au filtre PMT", hr);
}
hr = pPmtPin.QueryInterface(&pMapPmt);
@@ -868,6 +836,37 @@
return hr;
}
+// Mise en route du graphe :
+HRESULT graph_Run()
+{
+ CComQIPtr pControl(pGraph);
+
+ if (!pControl)
+ return E_NOINTERFACE;
+ return pControl->Run();
+}
+
+// Arrêt du graphe :
+HRESULT graph_Stop()
+{
+ CComQIPtr pControl(pGraph);
+
+ if (!pControl)
+ return E_NOINTERFACE;
+ return pControl->Stop();
+}
+
+// Interrogation de l'état du graphe :
+OAFilterState graph_GetState()
+{
+ CComQIPtr pControl(pGraph);
+ OAFilterState state;
+
+ if (!pControl || FAILED(pControl->GetState(1500, &state)))
+ return -1;
+ return state;
+}
+
HRESULT build_graph(void)
{
int res;
@@ -1007,14 +1006,7 @@
return hr;
}
- // derniers trucs
-
- hr = pGraph.QueryInterface(&pControl);
- if (FAILED(hr))
- return hr;
-
- hr = pControl->Run();
-
- return hr;
+ // mise en route
+ return graph_Run();
}
Modifié: trunk/graph.h
===================================================================
--- trunk/graph.h 2008-11-16 14:59:52 UTC (rev 140)
+++ trunk/graph.h 2008-11-20 12:15:06 UTC (rev 141)
@@ -30,9 +30,20 @@
#include
HRESULT build_graph(void); // retourne S_OK = pas d'erreur, != S_OK = erreur
+
void clean_dshow(void);
+
HRESULT init_vmr(void);
+// Mise en route du graphe :
+HRESULT graph_Run();
+
+// Arrêt du graphe :
+HRESULT graph_Stop();
+
+// Interrogation de l'état du graphe :
+OAFilterState graph_GetState();
+
extern CComPtr pMpeg2Data;
extern CComPtr pGraph;
Modifié: trunk/ini.cpp
===================================================================
--- trunk/ini.cpp 2008-11-16 14:59:52 UTC (rev 140)
+++ trunk/ini.cpp 2008-11-20 12:15:06 UTC (rev 141)
@@ -203,7 +203,7 @@
freq_scan.push_back(freq);
}
nr_multiplex++;
- } while (freq.canal_no != 0
+ } while (freq.canal_no != 0
&& nr_multiplex <= 99); // Buffer Overflow avec des chiffres > 99
}
}
@@ -495,8 +495,13 @@
canal.pmt_pid = (WORD)pNode->getInt(L"PMT");
canal.pcr_pid = (WORD)pNode->getInt(L"PCR");
- canal.video_pid = (WORD)pNode->getInt(L"Video");
- canal.mpeg4_pid = (WORD)pNode->getInt(L"Video_mpeg4");
+ if ((canal.video_pid = (UINT16)pNode->getInt(L"Video"))!=0)
+ canal.video_type = vst_MPEG2;
+ else if ((canal.video_pid = (UINT16)pNode->getInt(L"Video_mpeg4"))!=0)
+ canal.video_type = vst_H264;
+ else
+ canal.video_type = vst_Unknown;
+
canal.sons.nbr = (WORD)pNode->getInt(L"Nb_Son");
for (int i=0;igetInt(var);
swprintf_s(var, _countof(var), L"Son%i_Type", i);
- canal_son.type = (BYTE)pNode->getInt(var);
+ canal_son.type = (AudioStreamType)pNode->getInt(var);
swprintf_s(var, _countof(var), L"Son%i_Lang", i);
pNode->getStr(var, canal_son.lang, _countof(canal_son.lang));
@@ -565,12 +570,16 @@
oxml.put("PMT", canal.pmt_pid);
oxml.put("PCR", canal.pcr_pid);
- if (canal.video_pid > 0)
+ switch (canal.video_type) {
+ case vst_H264:
+ case vst_H264_encrypted:
+ oxml.put("Video_mpeg4", canal.video_pid);
+ break;
+ case vst_MPEG2:
+ default:
oxml.put("Video", canal.video_pid);
+ }
- if (canal.mpeg4_pid > 0)
- oxml.put("Video_mpeg4", canal.mpeg4_pid);
-
oxml.put("Nb_Son", canal.sons.nbr);
for (int j=0; jSetAspectRatioMode(etirer_video ? VMR_ARMODE_NONE : VMR_ARMODE_LETTER_BOX);
myprintf(L"%?échec SetAspectRatioMode, hr=0x%08x\n", FAILED(hr), hr);
+ // TODO : essayer d'éviter que ceci produise une erreur lors de, par exemple, la
+ // restauration de l'affichage depuis l'état minimisé.
hr = pVMRControl->SetVideoPosition(NULL, &rcDest);
myprintf(L"%?échec SetVideoPosition, hr=0x%08x\n", FAILED(hr), hr);
}
@@ -516,9 +518,17 @@
{"deu", "Allemand"},
{"spa", "Espagnol"},
{"ita", "Italien"},
- {"por", "Portugais"}
+ {"por", "Portugais"},
+ {"qaa", "Réservé"}
};
+ static const LPCSTR tblNomsAudio[] =
+ {
+ "MPG",
+ "AC3",
+ "EAC3"
+ };
+
const Chaine & canal_courant = Canaux[ixChaineCourante];
// Récupère le nom du menu avant de l'effacer
@@ -546,8 +556,8 @@
strcpy_s(langue, _countof(langue), son_courant.lang);
swprintf_s(tab, _countof(tab),
- L"Audio %i %S (%s)", i+1, langue,
- (son_courant.type==1) ? L"AC3" : L"MPG");
+ L"Audio %i %S (%S)", i+1, langue,
+ son_courant.type > ast_EAC3 ? "???" : tblNomsAudio[son_courant.type]);
AppendMenu(pistes, (i==ixSonCourant) ? MF_CHECKED : MF_UNCHECKED, IDM_PISTES_BASE+i, tab);
}
@@ -897,9 +907,11 @@
niData.update_tip();
}
+// Changement de chaîne, sélection par index dans la table
+// (mettre -1 pour désactiver la sélection de chaîne)
void zappe_index(int ixChaine)
{
- if (change_chaine(ixChaine)==0) {
+ if (change_chaine(ixChaine)==S_OK) {
update_all_menus(hMainWnd);
update_status_bar();
@@ -947,30 +959,6 @@
update_menus(hMainWnd, 1, update_ontop_menu);
}
-
-static int InitDshow(void) // retourne 0 = pas d'erreur, 1 = erreur
-{
- HRESULT hr = build_graph();
- if (FAILED(hr))
- return hr;
-
- if (Canaux.size()==0) {
- if (scan_dialog()!=IDOK)
- return S_FALSE;
- }
-
- if (Canaux.size() > 0) {
- restaure_chaine(sidChaineConfig);
- } else {
- affiche_erreurs(L"Aucune chaîne n'est dans le fichier");
- update_all_menus(hMainWnd);
- }
-
- set_volume(volumeCourant);
-
- return S_OK;
-}
-
static INT_PTR CALLBACK AboutDialogProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) {
switch (uMsg) {
case WM_INITDIALOG:
@@ -2112,7 +2100,7 @@
zappe_index(wID-IDM_CHAINES_BASE);
} else if (wID>=IDM_PISTES_BASE && wID=IDM_STOP_RECORD_BASE && wID=0;
- do {
+ for (;;) {
HRESULT hr;
if (!config_ok) {
@@ -2865,37 +2843,45 @@
affiche_erreurs(L"Configuration annulée.\nLe logiciel ne peut pas être exécuté.");
return -1;
}
- config_ok = check_config();
+ if (!check_config()) {
+ affiche_erreurs(L"Configuration incorrecte.\nVeuillez renseigner correctement tous les champs.");
+ continue;
+ }
}
- if (!config_ok) {
- affiche_erreurs(L"Configuration incorrecte.\nVeuillez renseigner correctement tous les champs.");
- continue;
- } else if (FAILED(hr = InitDshow())) {
- clean_dshow();
- affiche_erreurs(L"Erreur lors de l'initialisation.\nVeuillez corriger la configuration.", hr);
- config_ok = false;
-
- // Appeler une nouvelle fois, car certains filtres trouvent très malin d'appeler
- // CoUninitialize pour se protéger des usages non autorisés :
- CoInitializeEx(NULL,COINIT_MULTITHREADED);
+ if (SUCCEEDED(hr = build_graph())) {
+ if (Canaux.size()> 0 || scan_dialog()==IDOK) {
+ config_ok = true;
+ break; // tout est ok, on passe à la suite
+ }
}
- } while (!config_ok);
- // On a lancé avec le paramètre demandant de masquer la fenêtre
+ // Retour au départ :
+ clean_dshow();
+ affiche_erreurs(L"Erreur lors de l'initialisation.\nVeuillez corriger la configuration.", hr);
+ config_ok = false;
+
+ // Appeler une nouvelle fois, car certains filtres trouvent très malin d'appeler
+ // CoUninitialize pour se protéger des usages non autorisés :
+ CoInitializeEx(NULL,COINIT_MULTITHREADED);
+ }
+
+ if (!do_init_vmr())
+ return -1;
+
+ restaure_chaine(sidChaineConfig);
+
+ set_volume(volumeCourant);
+
if (cmdOptions[cmd_minimize].actif) {
+ // On a lancé avec le paramètre demandant de masquer la fenêtre
myprintf(L"minimize\n");
- if(suspend_minimized) {
- debranche();
- }
- } else {
- if (!do_init_vmr())
+ if(!suspend_minimized && !rebranche(true))
return -1;
+ } else {
+ if (ixChaine_ok(ixChaineCourante)) {
+ int nbChaines = (int)Canaux.size();
+ long freq_courante = Canaux[ixChaineCourante].frequence;
- int nbChaines = (int)Canaux.size();
-
- if (ixChaineCourante>=0 && ixChaineCourante 0) && (cmd_channel <= (int)Canaux.size())){
// Vérifie que la chaine passée en paramètre est connue
Modifié: trunk/main.h
===================================================================
--- trunk/main.h 2008-11-16 14:59:52 UTC (rev 140)
+++ trunk/main.h 2008-11-20 12:15:06 UTC (rev 141)
@@ -98,6 +98,8 @@
DWORD get_priority();
+// Changement de chaîne, sélection par index dans la table
+// (mettre -1 pour désactiver la sélection de chaîne)
void zappe_index(int ixChaine);
/**
Modifié: trunk/mpeg2defs.h
===================================================================
--- trunk/mpeg2defs.h 2008-11-16 14:59:52 UTC (rev 140)
+++ trunk/mpeg2defs.h 2008-11-20 12:15:06 UTC (rev 141)
@@ -76,6 +76,7 @@
operator const T & () const {return *pbeg;}
operator const T * () const {return pbeg;}
const T & operator () () const {return *pbeg;};
+ UINT32 size() const {return UINT32(pend-pbeg);}
};
template UINT8 unwrap_sequence(streamScanner limits, const T * tbl[])
@@ -480,6 +481,7 @@
//
mdt_Data_Broadcast_ID = 0x66,
mdt_AC3_Audio = 0x6a,
+ mdt_Extended_AC3_Audio = 0x7a,
//
mdt_Logical_Channel = 0x83
//
@@ -541,8 +543,10 @@
MDescriptorTag tag() const
{return static_cast(_tag);}
+ PUINT8 data() const
+ {return PUINT8(this+1);}
MDescriptor * next() const
- {return reinterpret_cast(PUINT8(this+1) + length);}
+ {return reinterpret_cast(data() + length);}
template const T & as() const // Dérivation vers un type de descripteur spécifique
{return *reinterpret_cast(this);}
};
@@ -553,7 +557,7 @@
const T & operator () () const
{return *reinterpret_cast(this+1);}
streamScanner subDescrRange() const
- {return streamScanner(this+1, PUINT8(this+1) + length);}
+ {return streamScanner(data(), data() + length);}
};
// Sous-descripteur générique pour les chaînes de caractères
@@ -1186,7 +1190,8 @@
{return UINT8(ac3_flags & 0xf0);}
};
-struct MDescriptor_6a_unwrapper {
+struct MDescriptor_6a_unwrapper
+{
const MDescriptor_6a & descr;
PUINT8 p_next;
UINT8uw * p_ac3_type;
@@ -1216,6 +1221,58 @@
}
};
+/*
+ Syntax No. of bits Offset
+ ----------------------------------------------------------
+ Enhanced_AC3_descriptor() {
+ descriptor_tag 8 0
+ descriptor_length 8 1
+ component_type_flag 1 2
+ bsid_flag 1 2
+ mainid_flag 1 2
+ asvc_flag 1 2
+ mixinfoexists 1 2
+ substream1_flag 1 2
+ substream2_flag 1 2
+ substream3_flag 1 2
+ if (component_type_flag)==1 { 3
+ component_type 8 +0
+ }
+ if (bsid_flag)==1 { +0
+ bsid 8 +0
+ }
+ if (mainid_flag)==1 { +0
+ mainid 8 +0
+ }
+ if (asvc_flag)==1 { +0
+ asvc 8 +0
+ }
+ if (substream1_flag)==1 { +0
+ substream1 8 +0
+ }
+ if (substream2_flag)==1 { +0
+ substream2 8 +0
+ }
+ if (substream3_flag)==1 { +0
+ substream3 8 +0
+ }
+ for (i=0;i0 ? PUINT8(this+1) : PUINT8(&flags);}
UINT8 get_flags() const
{return adaptation_field_length==0 ? 0 : flags;}
+ bool has_pcr() const
+ {return (get_flags() & AF_PCR_FLAG)!=0;}
+ const TS_PCR & get_pcr() const
+ {return *reinterpret_cast(beg_of_fields());}
PUINT8 next() const
{return PUINT8(&flags)+adaptation_field_length;}
};
Modifié: trunk/parse.cpp
===================================================================
--- trunk/parse.cpp 2008-11-16 14:59:52 UTC (rev 140)
+++ trunk/parse.cpp 2008-11-20 12:15:06 UTC (rev 141)
@@ -78,24 +78,32 @@
case st_MPEG_1_video: //ISO_IEC_11172_2_VIDEO, MPEG-1 video streams
case st_MPEG_2_video: //ISO_IEC_13818_2_VIDEO, MPEG-2 video streams
lpmt_e.video_pid=pid;
+ lpmt_e.video_type = vst_MPEG2;
break;
case st_MPEG_1_audio: //ISO_IEC_11172_3_AUDIO, MPEG-1 audio streams
case st_MPEG_2_audio: //ISO_IEC_13818_3_AUDIO, MPEG-2 audio streams
- lpmt_e.sons.ajoute(pid, 0);
+ lpmt_e.sons.ajoute(pid, ast_MPEG2);
break;
case st_PES_private:
for (; !sd; ++sd) {
- if (sd().tag() == mdt_AC3_Audio)
- lpmt_e.sons.ajoute(pid, 1);
+ switch (sd().tag()) {
+ case mdt_AC3_Audio:
+ lpmt_e.sons.ajoute(pid, ast_AC3);
+ break;
+ case mdt_Extended_AC3_Audio:
+ lpmt_e.sons.ajoute(pid, ast_EAC3);
+ break;
+ }
}
if (lpmt_e.sons.tbl[lpmt_e.sons.nbr-1].pid != pid)
- lpmt_e.autr.ajoute(pid);
+ lpmt_e.autr.ajoute(pid, ast_Unknown);
sd = se().descrRange(); // repartir du début au prochain 'for'
break;
case st_MPEG_4_video: //H264
- lpmt_e.mpeg4_pid=pid;
+ lpmt_e.video_pid=pid;
+ lpmt_e.video_type = vst_H264;
break;
}
@@ -327,7 +335,7 @@
for(i = prev_size; i < Canaux.size(); i++) {
const Chaine & canal = Canaux[i];
- if (canal.video_pid==0 && canal.mpeg4_pid == 0) {
+ if (canal.video_pid==0 && canal.video_type == vst_Unknown) {
//vire cette chaine
myprintf(L"Destruction [%S/%S]\n", canal.groupe, canal.nom);
Canaux.erase(Canaux.begin()+(i--));
Modifié: trunk/record.cpp
===================================================================
--- trunk/record.cpp 2008-11-16 14:59:52 UTC (rev 140)
+++ trunk/record.cpp 2008-11-20 12:15:06 UTC (rev 141)
@@ -235,10 +235,10 @@
int grab = getFreeGrabber();
if (grab>=0) {
const Chaine & canal = Canaux[ixChaine];
- NomFichierAvecDate nom_fichier(video_dir, getProgName(pProg), canal.nom, "ts");
- int video = canal.video_pid ? canal.video_pid : canal.mpeg4_pid;
- ISampleGrabberCB * pCallback = NULL;
- HANDLE hFile = nom_fichier.Create();
+ NomFichierAvecDate nom_fichier(video_dir, getProgName(pProg), canal.nom, "ts");
+ UINT16 video = canal.video_pid ;
+ ISampleGrabberCB * pCallback = NULL;
+ HANDLE hFile = nom_fichier.Create();
if (hFile != INVALID_HANDLE_VALUE) {
pCallback =
@@ -277,19 +277,23 @@
int grab = getFreeGrabber();
if (grab>=0) {
const Chaine & canal = Canaux[ixChaine];
+
+ if (canal.video_type!=vst_MPEG2) // PS en MPEG2 seulement pour le moment
+ return 0;
+
NomFichierAvecDate nom_fichier(video_dir, getProgName(pProg), canal.nom, "mpg");
- int video = canal.video_pid ? canal.video_pid : canal.mpeg4_pid;
- int son = canal.sons.tbl[ixSon].pid;
+ UINT16 video_pid = canal.video_pid;
+ UINT16 audio_pid = canal.sons.tbl[ixSon].pid;
ISampleGrabberCB * pCallback = NULL;
HANDLE hFile = nom_fichier.Create();
if (hFile != INVALID_HANDLE_VALUE) {
pCallback =
new CSampleGrabber(
- new CCapture_PS(hFile, video, son));
+ new CCapture_PS(hFile, video_pid, audio_pid));
if (pCallback!=NULL) {
- myprintf(L"Enregistre PS, video=%i, audio=%i\n", video, son);
+ myprintf(L"Enregistre PS, video=%i, audio=%i\n", video_pid, audio_pid);
enregistrements_actuels[grab].start(pCallback, ixChaine, pProg);
}
} else
Modifié: trunk/recprog.cpp
===================================================================
--- trunk/recprog.cpp 2008-11-16 14:59:52 UTC (rev 140)
+++ trunk/recprog.cpp 2008-11-20 12:15:06 UTC (rev 141)
@@ -1668,19 +1668,19 @@
int nbr_trouve = 0; // Comptage des pistes MPEG2 trouvées
for(int i=0; i