static PyObject *CmpObj_GetComponentInfo(ComponentObject *_self, PyObject *_args)
{
	PyObject *_res = NULL;
	OSErr _err;
	ComponentDescription cd;
	Handle componentName;
	Handle componentInfo;
	Handle componentIcon;
#ifndef GetComponentInfo
	PyMac_PRECHECK(GetComponentInfo);
#endif
	if (!PyArg_ParseTuple(_args, "O&O&O&",
	                      ResObj_Convert, &componentName,
	                      ResObj_Convert, &componentInfo,
	                      ResObj_Convert, &componentIcon))
		return NULL;
	_err = GetComponentInfo(_self->ob_itself,
	                        &cd,
	                        componentName,
	                        componentInfo,
	                        componentIcon);
	if (_err != noErr) return PyMac_Error(_err);
	_res = Py_BuildValue("O&",
	                     CmpDesc_New, &cd);
	return _res;
}
void LoadAudioUnits()
{
   ComponentDescription desc;
   Component component;
   
   desc.componentType = kAudioUnitType_Effect; //'aufx'
   desc.componentSubType = 0;
   desc.componentManufacturer = 0;
   desc.componentFlags = 0;
   desc.componentFlagsMask = 0;
   
   component = FindNextComponent(NULL, &desc);
   while (component != NULL) {
      ComponentDescription found;
      Handle nameHandle = NewHandle(0);
      GetComponentInfo(component, &found, nameHandle, 0, 0);
      HLock(nameHandle);
      int len = ((const char *)(*nameHandle))[0];
      wxString name((const char *)(*nameHandle)+1, len);
      HUnlock(nameHandle);
      DisposeHandle(nameHandle);

      Effect::RegisterEffect(new AudioUnitEffect(name, component));

      component = FindNextComponent (component, &desc);
   }
}
Exemple #3
0
// ImageCodecGetCodecInfo
//		Your component receives the ImageCodecGetCodecInfo request whenever an application calls the Image Compression Manager's GetCodecInfo function.
// Your component should return a formatted compressor information structure defining its capabilities.
// Both compressors and decompressors may receive this request.
pascal ComponentResult TextSubCodecGetCodecInfo(TextSubGlobals glob, CodecInfo *info)
{
	OSErr err = noErr;
	ComponentDescription desc;
	short resid;
	
	GetComponentInfo((Component)glob->self, &desc, 0, 0, 0);
	
	if (desc.componentSubType == kSubFormatSSA)
		resid = kSSASubCodecResourceID;
	else
		resid = kTextSubCodecResourceID;

	if (info == NULL) {
		err = paramErr;
	} else {
		CodecInfo **tempCodecInfo;

		err = GetComponentResource((Component)glob->self, codecInfoResourceType, resid, (Handle *)&tempCodecInfo);
		if (err == noErr) {
			*info = **tempCodecInfo;
			DisposeHandle((Handle)tempCodecInfo);
		}
	}

	return err;
}
void findGraphicsExporterComponents(_List& compList, _SimpleList& compIndex)
{
    ComponentDescription cd, cd2;
    Component c = 0;
    
    cd.componentType 			= GraphicsExporterComponentType;
    cd.componentSubType 		= 0;
    cd.componentManufacturer 	= 0;
    cd.componentFlags 			= 0;
    cd.componentFlagsMask 		= graphicsExporterIsBaseExporter;
    
    _String	fileFormat;
    
    while( ( c = FindNextComponent( c, &cd ) ) != 0 ) 
    {
    	 Handle     cInfo = NewHandle(256);
    	 GetComponentInfo (c,&cd2,cInfo,nil,nil);
    	 (*cInfo)[**cInfo+1] = 0;
    	 fileFormat = (char*)(*cInfo+1);
    	 if (fileFormat.sLength)
    	 {
    		 compList&& &fileFormat; 
    		 compIndex << (long)c;
    	 } 
    	 DisposeHandle(cInfo);
    }
} 
CAComponent::CAComponent (OSType inType, OSType inSubtype, OSType inManu)
	: mDesc (inType, inSubtype, inManu),
	  mManuName(0), mAUName(0), mCompName(0), mCompInfo (0)
{
	mComp = FindNextComponent (NULL, &mDesc);
	GetComponentInfo (Comp(), &mDesc, NULL, NULL, NULL);
}
CAComponent::CAComponent (const ComponentInstance& compInst) 
	: mComp (Component(compInst)), 
	  mManuName(0), 
	  mAUName(0), 
	  mCompName(0), 
	  mCompInfo (0) 
{ 
	GetComponentInfo (Comp(), &mDesc, NULL, NULL, NULL);
}
// 2.
// Create the Video Digitizer (using GWorld Pixmap as target mamory)
void QuicktimeLiveImageStream::createVideoDigitizer()
{
    // #define videoDigitizerComponentType = 'vdig'
    ComponentDescription video_component_description;
    video_component_description.componentType         = 'vdig'; /* A unique 4-byte code indentifying the command set */
    video_component_description.componentSubType      = 0;      /* Particular flavor of this instance */
    video_component_description.componentManufacturer = 0;      /* Vendor indentification */
    video_component_description.componentFlags        = 0;      /* 8 each for Component,Type,SubType,Manuf/revision */
    video_component_description.componentFlagsMask    = 0;      /* Mask for specifying which flags to consider in search, zero during registration */
    long num_video_components = CountComponents (&video_component_description);
    OSG_DEBUG << " available Video DigitizerComponents : " << num_video_components << std::endl;
    if (num_video_components)
    {
        Component aComponent = 0;
        short     aDeviceID  = 0;
        do
        {
            ComponentDescription full_video_component_description = video_component_description;
            aComponent = FindNextComponent(aComponent, &full_video_component_description);
            if (aComponent && (aDeviceID == m_videoDeviceID))
            {
                OSG_DEBUG << "Component" << std::endl;
                OSErr                err;
                Handle compName = NewHandle(256);
                Handle compInfo = NewHandle(256);
                err = GetComponentInfo( aComponent, &full_video_component_description, compName,compInfo,0);
                OSG_DEBUG << "    Name: " << pstr_printable((StringPtr)*compName) << std::endl;
                OSG_DEBUG << "    Desc: " << pstr_printable((StringPtr)*compInfo) << std::endl;
                //Capabilities
                VideoDigitizerComponent component_instance = OpenComponent(aComponent);
                m_vdig = component_instance;
                //Setup
                // Onscreen
                // Check capability and setting of Sequence Grabber
                GDHandle origDevice;
                CGrafPtr origPort;
                GetGWorld (&origPort, &origDevice);
                VideoDigitizerError error;
                Rect                destinationBounds;
                destinationBounds.left   = 0;
                destinationBounds.top    = 0;
                destinationBounds.right  = m_videoRectWidth;
                destinationBounds.bottom = m_videoRectHeight;                    
                error = VDSetPlayThruDestination(m_vdig, m_pixmap, &destinationBounds, 0, 0);
                //error = VDSetPlayThruGlobalRect(m_vdig, (GrafPtr)origPort, &destinationBounds);
                if (error != noErr)
                {
                    OSG_FATAL << "VDSetPlayThruDestination : error" << std::endl;
                }
                print_video_component_capability(component_instance);
                break;
            }
            ++aDeviceID;
        }
        while (0 != aComponent);
     }
}
CAComponent::CAComponent (const ComponentDescription& inDesc, CAComponent* next)
	: mManuName(0), mAUName(0), mCompName(0), mCompInfo (0)
{
	mComp = FindNextComponent ((next ? next->Comp() : NULL), const_cast<ComponentDescription*>(&inDesc));
	if (mComp)
		GetComponentInfo (Comp(), &mDesc, NULL, NULL, NULL);
	else
		memcpy (&mDesc, &inDesc, sizeof(ComponentDescription));
}
void pix_videoDarwin :: brightnessMess(float X)
{

    QTAtomContainer         atomContainer;
    QTAtom                  featureAtom;
    VDIIDCFeatureSettings   settings;
    ComponentDescription    desc;
    ComponentResult         result = paramErr;

    //check if device is IIDC
    GetComponentInfo((Component)m_vdig, &desc, NULL, NULL, NULL);
    if (vdSubtypeIIDC != desc.componentSubType){

        m_brightness = (unsigned short)(65536. * X);
        VDSetBrightness(m_vdig,&m_brightness);

        VDGetBrightness(m_vdig,&m_brightness);
        post("brightness is %d",m_brightness);
    }
    else
    {
    //IIDC stuff
    //these things are as stubborn as they are stupid - find one that conforms to spec!

    //vdIIDCFeatureBrightness
    result = VDIIDCGetFeaturesForSpecifier(m_vdig, vdIIDCFeatureBrightness, &atomContainer);
    if (noErr != result) {
        error("VDIIDCGetFeaturesForSpecifier returned %d",result);
    }

    featureAtom = QTFindChildByIndex(atomContainer, kParentAtomIsContainer,
                                         vdIIDCAtomTypeFeature, 1, NULL);
    if (0 == featureAtom) error("featureAtom not found");

    result = QTCopyAtomDataToPtr(atomContainer,
                                     QTFindChildByID(atomContainer, featureAtom,
                                     vdIIDCAtomTypeFeatureSettings,
                                     vdIIDCAtomIDFeatureSettings, NULL),
                                     true, sizeof(settings), &settings, NULL);

    settings.state.flags = (vdIIDCFeatureFlagOn |
                                        vdIIDCFeatureFlagManual |
                                        vdIIDCFeatureFlagRawControl);

    settings.state.value = X;

    result = QTSetAtomData(atomContainer,
                                       QTFindChildByID(atomContainer, featureAtom,
                                       vdIIDCAtomTypeFeatureSettings,
                                       vdIIDCAtomIDFeatureSettings, NULL),
                                       sizeof(settings), &settings);

    result = VDIIDCSetFeatures(m_vdig, atomContainer);

    }
}
void cHpiSubProviderFUMIComponent::GetInfo( std::deque<HpiInfo>& info ) const
{
    info.clear();

    // TODO bank id == bank num?
    Line( info, L"Bank Num", m_ctx.bank_num, UI8_SaHpiBankNum );

    GetComponentInfo( info );
    GetLogicalComponentInfo( info );
}
Exemple #11
0
gboolean
get_name_info_from_component (Component componentID,
    ComponentDescription * desc, gchar ** name, gchar ** info)
{
  Handle nameHandle = NewHandle (200);
  Handle infoHandle = NewHandle (200);
  gchar *tmpname;
  gchar *tmpinfo;
  OSErr result;
  gboolean ret = TRUE;

  result = GetComponentInfo (componentID, desc, nameHandle, infoHandle, NULL);
  if (result != noErr) {
    ret = FALSE;
    goto done;
  }
#if DEBUG_DUMP
  GST_LOG ("ComponentDescription dump");
  gst_util_dump_mem ((const guchar *) desc, sizeof (ComponentDescription));
  gst_util_dump_mem ((gpointer) * nameHandle, 200);
  gst_util_dump_mem ((gpointer) * infoHandle, 200);
  GST_LOG ("0x%x 0x%x", **((guint8 **) nameHandle), **((guint8 **) infoHandle));
#endif

  if (*nameHandle && name) {
    gsize read, written;

    tmpname = g_strndup ((*(char **) nameHandle) + 1,
        **((guint8 **) nameHandle));
    *name = g_convert_with_fallback (tmpname, -1, "ASCII", "MAC",
        (gchar *) " ", &read, &written, NULL);
    if (!*name)
      GST_WARNING ("read:%" G_GSIZE_FORMAT ", written:%" G_GSIZE_FORMAT, read,
          written);
    g_free (tmpname);
  }

  if (*infoHandle && info) {
    tmpinfo =
        g_strndup ((*(char **) infoHandle) + 1, **((guint8 **) infoHandle));
    *info =
        g_convert_with_fallback (tmpinfo, -1, "ASCII", "MAC", (gchar *) " ",
        NULL, NULL, NULL);
    g_free (tmpinfo);
  }

done:
  DisposeHandle (nameHandle);
  DisposeHandle (infoHandle);

  return ret;
}
void	CAComponent::SetCompInfo () const
{
	if (!mCompInfo) {
		Handle h1 = NewHandle(4);
		CAComponentDescription desc;
		OSStatus err = GetComponentInfo (Comp(), &desc, 0, h1, 0);
		if (err) return;
		HLock (h1);
		const_cast<CAComponent*>(this)->mCompInfo = CFStringCreateWithPascalString(NULL, (const unsigned char*)*h1, kCFStringEncodingMacRoman);

		DisposeHandle (h1);
	}
}
OSStatus		CAComponent::Restore (CFPropertyListRef &inData)
{
	if (mDesc.Restore (inData)) return -1;

	Clear();

	mComp = FindNextComponent (NULL, &mDesc);
		// this will restore the current flags...
	if (mComp)
		GetComponentInfo (Comp(), &mDesc, NULL, NULL, NULL);

	return noErr;
}
Exemple #14
0
//  SGSettingsDialog with the "Compression" panel removed
static OSErr MinimalSGSettingsDialog(SeqGrabComponent seqGrab,
                                     SGChannel sgchanVideo, WindowPtr gMonitor)
{
        OSErr err;
        Component *panelListPtr = NULL;
        UInt8 numberOfPanels = 0;

        ComponentDescription cd = { SeqGrabPanelType, VideoMediaType, 0, 0, 0 };
        Component c = 0;
        Component *cPtr = NULL;

        numberOfPanels = CountComponents(&cd);
        panelListPtr =
            (Component *) NewPtr(sizeof(Component) * (numberOfPanels + 1));

        cPtr = panelListPtr;
        numberOfPanels = 0;
        CFStringRef compressionCFSTR = CFSTR("Compression");
        do {
                ComponentDescription compInfo;
                c = FindNextComponent(c, &cd);
                if (c) {
                        Handle hName = NewHandle(0);
                        GetComponentInfo(c, &compInfo, hName, NULL, NULL);
                        CFStringRef nameCFSTR =
                            CFStringCreateWithPascalString(kCFAllocatorDefault,
                                                           (unsigned char
                                                            *)(*hName),
                                                           kCFStringEncodingASCII);
                        if (CFStringCompare
                            (nameCFSTR, compressionCFSTR,
                             kCFCompareCaseInsensitive) != kCFCompareEqualTo) {
                                *cPtr++ = c;
                                numberOfPanels++;
                        }
                        DisposeHandle(hName);
                }
        } while (c);

        if ((err =
             SGSettingsDialog(seqGrab, sgchanVideo, numberOfPanels,
                              panelListPtr, seqGrabSettingsPreviewOnly,
                              (SGModalFilterUPP)
                              NewSGModalFilterUPP(SeqGrabberModalFilterProc),
                              (long)gMonitor))) {
                return err;
        }
        return 0;
}
Exemple #15
0
void pix_videoDarwin :: gainMess(float X)
{

    QTAtomContainer         atomContainer;
    QTAtom                  featureAtom;
    VDIIDCFeatureSettings   settings;
    ComponentDescription    desc;
    ComponentResult         result = paramErr;

    //check if device is IIDC
    GetComponentInfo((Component)m_vdig, &desc, NULL, NULL, NULL);
    if (vdSubtypeIIDC == desc.componentSubType){

    //IIDC stuff
    //vdIIDCFeatureGain
    result = VDIIDCGetFeaturesForSpecifier(m_vdig, vdIIDCFeatureWhiteBalanceU, &atomContainer);
    if (noErr != result) {
        error("VDIIDCGetFeaturesForSpecifier vdIIDCFeatureExposure returned %d",result);
    }

    featureAtom = QTFindChildByIndex(atomContainer, kParentAtomIsContainer,
                                         vdIIDCAtomTypeFeature, 1, NULL);
    if (0 == featureAtom) error("featureAtom vdIIDCFeatureExposure not found");

    result = QTCopyAtomDataToPtr(atomContainer,
                                     QTFindChildByID(atomContainer, featureAtom,
                                     vdIIDCAtomTypeFeatureSettings,
                                     vdIIDCAtomIDFeatureSettings, NULL),
                                     true, sizeof(settings), &settings, NULL);

    settings.state.flags = (vdIIDCFeatureFlagOn |
                                        vdIIDCFeatureFlagManual |
                                        vdIIDCFeatureFlagRawControl);

    settings.state.value = X;

    result = QTSetAtomData(atomContainer,
                                       QTFindChildByID(atomContainer, featureAtom,
                                       vdIIDCAtomTypeFeatureSettings,
                                       vdIIDCAtomIDFeatureSettings, NULL),
                                       sizeof(settings), &settings);

    result = VDIIDCSetFeatures(m_vdig, atomContainer);

    }
}
void 		CAComponent::SetCompNames () const
{
	if (!mCompName) {
		Handle h1 = NewHandle(4);
		CAComponentDescription desc;
		OSStatus err = GetComponentInfo (Comp(), &desc, h1, 0, 0);
		
		if (err) { DisposeHandle(h1); return; }
		
		HLock(h1);
		char* ptr1 = *h1;
		// Get the manufacturer's name... look for the ':' character convention
		int len = *ptr1++;
		char* displayStr = 0;

		const_cast<CAComponent*>(this)->mCompName = CFStringCreateWithPascalString(NULL, (const unsigned char*)*h1, kCFStringEncodingMacRoman);
				
		for (int i = 0; i < len; ++i) {
			if (ptr1[i] == ':') { // found the name
				ptr1[i] = 0;
				displayStr = ptr1;
				break;
			}
		}
		
		if (displayStr)
		{
			const_cast<CAComponent*>(this)->mManuName = CFStringCreateWithCString(NULL, displayStr, kCFStringEncodingMacRoman);
										
			//move displayStr ptr past the manu, to the name
			// we move the characters down a index, because the handle doesn't have any room
			// at the end for the \0
			int i = strlen(displayStr), j = 0;
			while (displayStr[++i] == ' ' && i < len)
					;
			while (i < len)
				displayStr[j++] = displayStr[i++];
			displayStr[j] = 0;

			const_cast<CAComponent*>(this)->mAUName = CFStringCreateWithCString(NULL, displayStr, kCFStringEncodingMacRoman);
		} 
		
		DisposeHandle (h1);
	}
}
Exemple #17
0
ComponentResult FFAvi_MovieImportOpen(ff_global_ptr storage, ComponentInstance self)
{
	ComponentResult result = noErr;
    ComponentDescription descout;
	
    GetComponentInfo((Component)self, &descout, 0, 0, 0);
	
	storage = malloc(sizeof(ff_global_context));
	if(!storage) goto bail;
	
	memset(storage, 0, sizeof(ff_global_context));
	storage->ci = self;
	
	SetComponentInstanceStorage(storage->ci, (Handle)storage);
	
	storage->componentType = descout.componentSubType;
	storage->movieLoadState = kMovieLoadStateLoading;
bail:
		return result;
} /* FFAvi_MovieImportOpen() */
Exemple #18
0
static int
AudioFilePlayer_SetDestination(AudioFilePlayer * afp, AudioUnit * inDestUnit)
{
    /*if (afp->mConnected) throw static_cast<OSStatus>(-1); *//* can't set dest if already engaged */
    if (afp->mConnected)
        return 0;

    SDL_memcpy(&afp->mPlayUnit, inDestUnit, sizeof(afp->mPlayUnit));

    OSStatus result = noErr;


    /* we can "down" cast a component instance to a component */
    ComponentDescription desc;
    result = GetComponentInfo((Component) * inDestUnit, &desc, 0, 0, 0);
    if (result)
        return 0;               /*THROW_RESULT("GetComponentInfo") */

    /* we're going to use this to know which convert routine to call
       a v1 audio unit will have a type of 'aunt'
       a v2 audio unit will have one of several different types. */
    if (desc.componentType != kAudioUnitComponentType) {
        result = badComponentInstance;
        /*THROW_RESULT("BAD COMPONENT") */
        if (result)
            return 0;
    }

    /* Set the input format of the audio unit. */
    result = AudioUnitSetProperty(*inDestUnit,
                                  kAudioUnitProperty_StreamFormat,
                                  kAudioUnitScope_Input,
                                  0,
                                  &afp->mFileDescription,
                                  sizeof(afp->mFileDescription));
    /*THROW_RESULT("AudioUnitSetProperty") */
    if (result)
        return 0;
    return 1;
}
void	AUControlGroup::AddAUInfo (		AUCarbonViewBase *			auView,
										const Point &				inLocation,
										const SInt16 				inRightOffset,
										const SInt16				inTotalWidth)
{
#if !__LP64__
   // get component info
	ComponentDescription desc;
    Handle h1 = NewHandleClear(4);
	OSStatus err = GetComponentInfo ((Component)auView->GetEditAudioUnit(), &desc, h1, 0, 0);

    if (err == noErr) {
        // Get the manufacturer's name... look for the ':' character convention
        HLock(h1);
        char* ptr1 = *h1;
        int len = *ptr1++;
        char* displayStr = 0;

        for (int i = 0; i < len; ++i) {
            if (ptr1[i] == ':') { // found the name
                ptr1[i++] = 0;
                displayStr = ptr1;
                break;
            }
        }

        // localize as necessary:
        if (!sLocalized) {
            CFBundleRef mainBundle = CFBundleGetBundleWithIdentifier(kLocalizedStringBundle_AUView);
            if (mainBundle) {
                kStringManufacturer = CFCopyLocalizedStringFromTableInBundle(
                                            kAUViewLocalizedStringKey_Manufacturer, kLocalizedStringTable_AUView,
                                            mainBundle, CFSTR("Manufacturer title string"));
                sLocalized = true;
            }
        }

        // display strings
        ControlRef newControl;
        Rect r;
        r.top = SInt16(inLocation.v);		r.bottom = SInt16(inLocation.v) + 16;
        ControlFontStyleRec fontStyle;
        fontStyle.flags = kControlUseFontMask | kControlUseJustMask;
        fontStyle.font = kControlFontSmallBoldSystemFont;

        // display manufacturer string
        if (displayStr) {
            CFMutableStringRef mfrstring = CFStringCreateMutable(NULL, 0);
            CFStringAppend(mfrstring, kStringManufacturer);		// "Manufacturer"
            CFStringAppend(mfrstring, kAUViewUnlocalizedString_TitleSeparator);
                                                                // "Manufacturer: "
            CFStringRef mfrname = CFStringCreateWithCString(NULL, displayStr, kCFStringEncodingUTF8);
            if (mfrname) {
                CFStringAppend(mfrstring, mfrname);	// "Manufacturer: MFRName"
                CFRelease (mfrname);
            }

            r.left = inLocation.h + inRightOffset;
			r.right = inLocation.h + inTotalWidth - 28;
			fontStyle.just = teFlushRight;

            verify_noerr(CreateStaticTextControl(auView->GetCarbonWindow(), &r, mfrstring, &fontStyle, &newControl));
            verify_noerr(auView->EmbedControl(newControl));
            CFRelease (mfrstring);

            //move displayStr ptr past the manu, to the name
            // we move the characters down an index, because the handle doesn't have any room
            // at the end for the \0
			int i = strlen(displayStr), j = 0;
			while (displayStr[++i] == ' ' && i < len)
				;
			while (i < len)
				displayStr[j++] = displayStr[i++];
			displayStr[j] = 0;
        } else {
			displayStr = ptr1;
			int i = 0, j = 0;
			do {
				displayStr[j] = displayStr[i];
				++j; ++i;
			} while (i < len);

			displayStr[j] = 0;
        }

        // display AudioUnit string
        r.left = inLocation.h;	r.right = r.left + inRightOffset;
        fontStyle.just = 0;

        CFMutableStringRef cfstr = CFStringCreateMutable(NULL, 0);
        CFStringAppend(cfstr, kAUViewLocalizedStringKey_AudioUnit);		// "Audio Unit"
        CFStringAppend(cfstr, kAUViewUnlocalizedString_TitleSeparator);
                                                        // "Audio Unit: "

		CFStringRef auname = CFStringCreateWithCString(NULL, displayStr, kCFStringEncodingUTF8);
		CFStringAppend(cfstr, auname);				// "Audio Unit: AUName"
		CFRelease (auname);

        verify_noerr(CreateStaticTextControl(auView->GetCarbonWindow(), &r, cfstr, &fontStyle, &newControl));

		// size text control correctly
		Boolean bValue = false;
		SetControlData(newControl, kControlEntireControl, 'stim' /* kControlStaticTextIsMultilineTag */, sizeof(Boolean), &bValue);
		SInt16 baseLineOffset;
		Rect bestRect;
		err = GetBestControlRect(newControl, &bestRect, &baseLineOffset);
		if (err == noErr)
		{
			int width = (bestRect.right - bestRect.left) + 1;
			int height = (bestRect.bottom - bestRect.top) + 1;
			SizeControl (newControl, width, height);
		}

        verify_noerr(auView->EmbedControl(newControl));
        CFRelease (cfstr);
    }

	DisposeHandle (h1);
#endif
}
/////////////////////////////////////////////////////////
//
// DlgProc
//
//        The DlgProc function is an application-defined
//        function that processes messages sent to the dialog
//
// Parameters:
//        HWND hwnd      : [in] handle to dialog window
//        UINT uMsg      : [in] message identifier
//        WPARAM wParam  : [in] first message parameter
//        LPARAM lParam  : [in] second message parameter
//
// Return Values:
//        The return value is the result of the
//        message processing and depends on the message sent
//
/////////////////////////////////////////////////////////
BOOL CALLBACK DlgProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM /* lParam */)
{
    BOOL bReturn = FALSE; // the value to return
    switch (uMsg)
    {
        case WM_INITDIALOG:
        {
            // Initialize the COM
            if (FAILED(CoInitialize(NULL)))
            {
                MessageBoxW(NULL, L"Unable to initialize the COM library",
                            gc_wszAppName, MB_OK | MB_ICONINFORMATION);
                PostMessage(hwnd, WM_CLOSE, 0, 0);
                break;
            }

            // Gather and show the information we're interested in

            // Check out if Microsoft Tablet PC Platform components of the
            // Microsoft Windows XP Professional Operating System are enabled
            int bTabletPC = GetSystemMetrics(SM_TABLETPC);
            SetDlgItemTextW(hwnd, IDC_TABLETPC,
                            bTabletPC ? L"Available" : L"Not available");

            // Get the version of the Text Services Framework components
            SInfo info;
            if (GetComponentInfo(CLSID_TF_ThreadMgr, info) == TRUE)
            {
                SetDlgItemTextW(hwnd, IDC_TSF, info.wchVersion);
            }

            // Find out the name and the version of the default handwriting recognizer
            // Create the enumerator for the installed recognizers
            IInkRecognizers* pIInkRecognizers = NULL;
            HRESULT hr = CoCreateInstance(CLSID_InkRecognizers,
                                          NULL,
                                          CLSCTX_INPROC_SERVER,
                                          IID_IInkRecognizers,
                                          (void **)&pIInkRecognizers);
            if (SUCCEEDED(hr))
            {
                IInkRecognizer* pIInkRecognizer = NULL;
                // The first parameter is the language id, passing 0 means that the language
                // id will be retrieved using the user default-locale identifier
                hr = pIInkRecognizers->GetDefaultRecognizer(0, &pIInkRecognizer);
                if (SUCCEEDED(hr))
                {
                    // Get the recognizer's friendly name
                    BSTR bstr;
                    if (SUCCEEDED(pIInkRecognizer->get_Name(&bstr)))
                    {
                        SetDlgItemTextW(hwnd, IDC_HWR_NAME, bstr);
                        SysFreeString(bstr);
                    }
                    else
                    {
                        SetDlgItemTextW(hwnd, IDC_HWR_NAME, L"Failed");
                    }
                    // Get the recognizer's vendor info
                    if (SUCCEEDED(pIInkRecognizer->get_Vendor(&bstr)))
                    {
                        SetDlgItemTextW(hwnd, IDC_HWR_VENDOR, bstr);
                        SysFreeString(bstr);
                    }
                    else
                    {
                        SetDlgItemTextW(hwnd, IDC_HWR_VENDOR, L"Failed");
                    }
                    // Release it
                    pIInkRecognizer->Release();
                    pIInkRecognizer = NULL;
                }
                // Release the collection object
                pIInkRecognizers->Release();
                pIInkRecognizers = NULL;
            }

            // Find out the name and the version of the default speech recognizer

            // Open key to find path of application
            HKEY hkeySpeech;
            if (RegOpenKeyExW(HKEY_LOCAL_MACHINE, gc_wszSpeechKey, 0, KEY_READ,
                            &hkeySpeech) == ERROR_SUCCESS)
            {
                // Query value of key to get the name of the component
                WCHAR wchValue[265];
                ULONG cSize = sizeof(wchValue);
                if (RegQueryValueExW(hkeySpeech, L"DefaultDefaultTokenId", NULL, NULL,
                                    (BYTE*)wchValue, &cSize) == ERROR_SUCCESS)
                {
                    int ndx = lstrlenW(L"HKEY_LOCAL_MACHINE\\");
                    int len = lstrlenW(wchValue);
                    if (ndx < len
                        && RegOpenKeyExW(HKEY_LOCAL_MACHINE, &wchValue[ndx], 0,
                                         KEY_READ, &hkeySpeech) == ERROR_SUCCESS)
                    {
                        cSize = sizeof(wchValue);
                        if (RegQueryValueExW(hkeySpeech, NULL, NULL, NULL,
                                             (BYTE*)wchValue, &cSize) == ERROR_SUCCESS)
                        {
                            SetDlgItemTextW(hwnd, IDC_SPR_NAME, wchValue);
                        }
                    }
                }
            }

            // Find out which of the controls are installed and show their version info
            for (int i = 0, j = 0; i < NUM_CONTROLS; i++)
            {
                // Get the component info
                CLSID clsid;
                if (SUCCEEDED(CLSIDFromProgID(gc_wszProgId[i], &clsid))
                    && GetComponentInfo(clsid, info) == TRUE)
                {
                    SetDlgItemTextW(hwnd, gc_uiCtrlId[j][0], info.wchName);
                    SetDlgItemTextW(hwnd, gc_uiCtrlId[j][1], info.wchVersion);
                    j++;
                }
            }

            // Done with the COM
            CoUninitialize();

            break;
        }
        case WM_DESTROY:

            PostQuitMessage(0);
            break;

        case WM_COMMAND:
            switch (LOWORD(wParam))
            {
                case IDCLOSE:   // User clicked on the "Close" button in the dialog.
                case IDCANCEL:  // User clicked the close button ([X]) in the caption
                                // or pressed Alt+F4.
                    DestroyWindow(hwnd);
                    bReturn = TRUE;
                    break;
            }
            break;
    }

    return bReturn;
}
Exemple #21
0
// init driver
static int init(sh_video_t *sh){
#ifndef CONFIG_QUICKTIME
    long result = 1;
#endif
    ComponentResult cres;
    ComponentDescription desc;
    Component prev=NULL;
    CodecInfo cinfo;	// for ImageCodecGetCodecInfo()
    ImageSubCodecDecompressCapabilities icap; // for ImageCodecInitialize()

    codec_initialized = 0;
#ifdef CONFIG_QUICKTIME
    EnterMovies();
#else

#ifdef WIN32_LOADER
    Setup_LDT_Keeper();
#endif

    //preload quicktime.qts to avoid the problems caused by the hardcoded path inside the dll
    qtime_qts = LoadLibraryA("QuickTime.qts");
    if(!qtime_qts){
    mp_msg(MSGT_DECVIDEO,MSGL_ERR,"unable to load QuickTime.qts\n" );
    return 0;
    }

    handler = LoadLibraryA("qtmlClient.dll");
    if(!handler){
    mp_msg(MSGT_DECVIDEO,MSGL_ERR,"unable to load qtmlClient.dll\n");
    return 0;
    }

    InitializeQTML = (OSErr (*)(long))GetProcAddress(handler, "InitializeQTML");
    EnterMovies = (OSErr (*)(void))GetProcAddress(handler, "EnterMovies");
    FindNextComponent = (Component (*)(Component,ComponentDescription*))GetProcAddress(handler, "FindNextComponent");
    CountComponents = (long (*)(ComponentDescription*))GetProcAddress(handler, "CountComponents");
    GetComponentInfo = (OSErr (*)(Component,ComponentDescription*,Handle,Handle,Handle))GetProcAddress(handler, "GetComponentInfo");
    OpenComponent = (ComponentInstance (*)(Component))GetProcAddress(handler, "OpenComponent");
    ImageCodecInitialize = (ComponentResult (*)(ComponentInstance,ImageSubCodecDecompressCapabilities *))GetProcAddress(handler, "ImageCodecInitialize");
    ImageCodecGetCodecInfo = (ComponentResult (*)(ComponentInstance,CodecInfo *))GetProcAddress(handler, "ImageCodecGetCodecInfo");
    ImageCodecBeginBand = (ComponentResult (*)(ComponentInstance,CodecDecompressParams *,ImageSubCodecDecompressRecord *,long))GetProcAddress(handler, "ImageCodecBeginBand");
    ImageCodecPreDecompress = (ComponentResult (*)(ComponentInstance,CodecDecompressParams *))GetProcAddress(handler, "ImageCodecPreDecompress");
    ImageCodecBandDecompress = (ComponentResult (*)(ComponentInstance,CodecDecompressParams *))GetProcAddress(handler, "ImageCodecBandDecompress");
    GetGWorldPixMap = (PixMapHandle (*)(GWorldPtr))GetProcAddress(handler, "GetGWorldPixMap");
    QTNewGWorldFromPtr = (OSErr(*)(GWorldPtr *,OSType,const Rect *,CTabHandle,void*,GWorldFlags,void *,long))GetProcAddress(handler, "QTNewGWorldFromPtr");
    NewHandleClear = (OSErr(*)(Size))GetProcAddress(handler, "NewHandleClear");
    //     = GetProcAddress(handler, "");

    if(!InitializeQTML || !EnterMovies || !FindNextComponent || !ImageCodecBandDecompress){
	mp_msg(MSGT_DECVIDEO,MSGL_ERR,"invalid qtmlClient.dll!\n");
	return 0;
    }

    result=InitializeQTML(6+16);
//    result=InitializeQTML(0);
    mp_msg(MSGT_DECVIDEO,MSGL_DBG2,"InitializeQTML returned %li\n",result);
//    result=EnterMovies();
//    printf("EnterMovies->%d\n",result);
#endif /* CONFIG_QUICKTIME */

#if 0
    memset(&desc,0,sizeof(desc));
    while((prev=FindNextComponent(prev,&desc))){
	ComponentDescription desc2;
	unsigned char* c1=&desc2.componentType;
	unsigned char* c2=&desc2.componentSubType;
	memset(&desc2,0,sizeof(desc2));
//	printf("juhee %p (%p)\n",prev,&desc);
	GetComponentInfo(prev,&desc2,NULL,NULL,NULL);
	mp_msg(MSGT_DECVIDEO,MSGL_DGB2,"DESC: %c%c%c%c/%c%c%c%c [0x%X/0x%X] 0x%X\n",
	    c1[3],c1[2],c1[1],c1[0],
	    c2[3],c2[2],c2[1],c2[0],
	    desc2.componentType,desc2.componentSubType,
	    desc2.componentFlags);
    }
#endif


    memset(&desc,0,sizeof(desc));
    desc.componentType= (((unsigned char)'i')<<24)|
			(((unsigned char)'m')<<16)|
			(((unsigned char)'d')<<8)|
			(((unsigned char)'c'));
#if 0
    desc.componentSubType=
		    (((unsigned char)'S'<<24))|
			(((unsigned char)'V')<<16)|
			(((unsigned char)'Q')<<8)|
			(((unsigned char)'3'));
#else
    desc.componentSubType = bswap_32(sh->format);
#endif
    desc.componentManufacturer=0;
    desc.componentFlags=0;
    desc.componentFlagsMask=0;

    mp_msg(MSGT_DECVIDEO,MSGL_DBG2,"Count = %ld\n",CountComponents(&desc));
    prev=FindNextComponent(NULL,&desc);
    if(!prev){
	mp_msg(MSGT_DECVIDEO,MSGL_ERR,"Cannot find requested component\n");
	return 0;
    }
    mp_msg(MSGT_DECVIDEO,MSGL_DBG2,"Found it! ID = %p\n",prev);

    ci=OpenComponent(prev);
    mp_msg(MSGT_DECVIDEO,MSGL_DBG2,"ci=%p\n",ci);

    memset(&icap,0,sizeof(icap));
    cres=ImageCodecInitialize(ci,&icap);
    mp_msg(MSGT_DECVIDEO,MSGL_DBG2,"ImageCodecInitialize->%#x  size=%d (%d)\n",cres,icap.recordSize,icap.decompressRecordSize);

    memset(&cinfo,0,sizeof(cinfo));
    cres=ImageCodecGetCodecInfo(ci,&cinfo);
    mp_msg(MSGT_DECVIDEO,MSGL_DBG2,"Flags: compr: 0x%X  decomp: 0x%X format: 0x%X\n",
	cinfo.compressFlags, cinfo.decompressFlags, cinfo.formatFlags);
    mp_msg(MSGT_DECVIDEO,MSGL_DBG2,"Codec name: %.*s\n",((unsigned char*)&cinfo.typeName)[0],
	((unsigned char*)&cinfo.typeName)+1);

    //make a yuy2 gworld
    OutBufferRect.top=0;
    OutBufferRect.left=0;
    OutBufferRect.right=sh->disp_w;
    OutBufferRect.bottom=sh->disp_h;

    //Fill the imagedescription for our SVQ3 frame
    //we can probably get this from Demuxer
#if 0
    framedescHandle=(ImageDescriptionHandle)NewHandleClear(sizeof(ImageDescription)+200);
    printf("framedescHandle=%p  *p=%p\n",framedescHandle,*framedescHandle);
{ FILE* f=fopen("/root/.wine/fake_windows/IDesc","r");
  if(!f) printf("filenot found: IDesc\n");
  fread(*framedescHandle,sizeof(ImageDescription)+200,1,f);
  fclose(f);
}
#else
    if(!sh->ImageDesc) sh->ImageDesc=(sh->bih+1); // hack for SVQ3-in-AVI
    mp_msg(MSGT_DECVIDEO,MSGL_DBG2,"ImageDescription size: %d\n",((ImageDescription*)(sh->ImageDesc))->idSize);
    framedescHandle=(ImageDescriptionHandle)NewHandleClear(((ImageDescription*)(sh->ImageDesc))->idSize);
    memcpy(*framedescHandle,sh->ImageDesc,((ImageDescription*)(sh->ImageDesc))->idSize);
    dump_ImageDescription(*framedescHandle);
#endif
//Find codecscomponent for video decompression
//    result = FindCodec ('SVQ1',anyCodec,&compressor,&decompressor );
//    printf("FindCodec SVQ1 returned:%i compressor: 0x%X decompressor: 0x%X\n",result,compressor,decompressor);

    sh->context = (void *)kYUVSPixelFormat;
#if 1
    {
	int imgfmt = sh->codec->outfmt[sh->outfmtidx];
	int qt_imgfmt;
    switch(imgfmt)
    {
	case IMGFMT_YUY2:
	    qt_imgfmt = kYUVSPixelFormat;
	    break;
	case IMGFMT_YVU9:
	    qt_imgfmt = 0x73797639; //kYVU9PixelFormat;
	    break;
	case IMGFMT_YV12:
	    qt_imgfmt = 0x79343230;
	    break;
	case IMGFMT_UYVY:
	    qt_imgfmt = kUYVY422PixelFormat;
	    break;
	case IMGFMT_YVYU:
	    qt_imgfmt = kYVYU422PixelFormat;
	    imgfmt = IMGFMT_YUY2;
	    break;
	case IMGFMT_RGB16:
	    qt_imgfmt = k16LE555PixelFormat;
	    break;
	case IMGFMT_BGR24:
	    qt_imgfmt = k24BGRPixelFormat;
	    break;
	case IMGFMT_BGR32:
	    qt_imgfmt = k32BGRAPixelFormat;
	    break;
	case IMGFMT_RGB32:
	    qt_imgfmt = k32RGBAPixelFormat;
	    break;
	default:
	    mp_msg(MSGT_DECVIDEO,MSGL_ERR,"Unknown requested csp\n");
	    return 0;
    }
    mp_msg(MSGT_DECVIDEO,MSGL_DBG2,"imgfmt: %s qt_imgfmt: %.4s\n", vo_format_name(imgfmt), (char *)&qt_imgfmt);
    sh->context = (void *)qt_imgfmt;
    if(!mpcodecs_config_vo(sh,sh->disp_w,sh->disp_h,imgfmt)) return 0;
    }
#else
    if(!mpcodecs_config_vo(sh,sh->disp_w,sh->disp_h,IMGFMT_YUY2)) return 0;
#endif

    return 1;
}