DSUtil.pas 195 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017
  1. (*********************************************************************
  2. * DSPack 2.3.3 *
  3. * *
  4. * home page : http://www.progdigy.com *
  5. * email : hgourvest@progdigy.com *
  6. * Thanks to Michael Andersen. (DSVideoWindowEx) *
  7. * *
  8. * date : 21-02-2003 *
  9. * *
  10. * The contents of this file are used with permission, subject to *
  11. * the Mozilla Public License Version 1.1 (the "License"); you may *
  12. * not use this file except in compliance with the License. You may *
  13. * obtain a copy of the License at *
  14. * http://www.mozilla.org/MPL/MPL-1.1.html *
  15. * *
  16. * Software distributed under the License is distributed on an *
  17. * "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or *
  18. * implied. See the License for the specific language governing *
  19. * rights and limitations under the License. *
  20. * *
  21. * Contributor(s) *
  22. * Peter J. Haas <DSPack@pjh2.de> *
  23. * Andriy Nevhasymyy <a.n@email.com> *
  24. * Milenko Mitrovic <dcoder@dsp-worx.de> *
  25. * Michael Andersen <michael@mechdata.dk> *
  26. * Martin Offenwanger <coder@dsplayer.de> *
  27. * *
  28. *********************************************************************)
  29. {
  30. @abstract(Methods & usefull Class for Direct Show programming.)
  31. @author(Henri Gourvest: hgourvest@progdigy.com)
  32. @created(Mar 14, 2002)
  33. @lastmod(Oct 24, 2003)
  34. }
  35. unit DSUtil;
  36. {$B-} // needed at least for TSysDevEnum.FilterIndexOfFriendlyName
  37. {$I jedi.inc}
  38. {$IFDEF COMPILER7_UP}
  39. {$WARN UNSAFE_CODE OFF}
  40. {$WARN UNSAFE_TYPE OFF}
  41. {$WARN UNSAFE_CAST OFF}
  42. {$ENDIF}
  43. interface
  44. uses
  45. //{$IFDEF COMPILER6_UP} Variants, {$ENDIF}
  46. Variants,
  47. Windows, Controls, SysUtils, ActiveX, Classes, MMSystem, DirectShow9, WMF9,
  48. DirectDraw;
  49. const
  50. IID_IPropertyBag : TGUID = '{55272A00-42CB-11CE-8135-00AA004BB851}';
  51. IID_ISpecifyPropertyPages : TGUID = '{B196B28B-BAB4-101A-B69C-00AA00341D07}';
  52. IID_IPersistStream : TGUID = '{00000109-0000-0000-C000-000000000046}';
  53. IID_IMoniker : TGUID = '{0000000F-0000-0000-C000-000000000046}';
  54. // MS Mepg4 DMO
  55. MEDIASUBTYPE_MP42 : TGUID = '{3234504D-0000-0010-8000-00AA00389B71}';
  56. // DIVX
  57. MEDIASUBTYPE_DIVX : TGUID = '{58564944-0000-0010-8000-00AA00389B71}';
  58. // VoxWare MetaSound
  59. MEDIASUBTYPE_VOXWARE : TGUID = '{00000075-0000-0010-8000-00AA00389B71}';
  60. MiliSecPerDay : Cardinal = 86400000;
  61. MAX_TIME : Int64 = $7FFFFFFFFFFFFFFF;
  62. bits555: array[0..2] of DWord = ($007C00, $0003E0, $00001F);
  63. bits565: array[0..2] of DWord = ($00F800, $0007E0, $00001F);
  64. bits888: array[0..2] of DWord = ($FF0000, $00FF00, $0000FF);
  65. ////////////////////////////////////////////////////////////////////////////////
  66. // DIVX ressources translated from latest OpenDivx DirectX Codec
  67. // divx
  68. CLSID_DIVX : TGUID = '{78766964-0000-0010-8000-00aa00389b71}';
  69. // DIVX
  70. CLSID_DivX_U : TGUID = '{58564944-0000-0010-8000-00aa00389b71}';
  71. // dvx1
  72. CLSID_DivX_ : TGUID = '{31787664-0000-0010-8000-00aa00389b71}';
  73. // DVX1
  74. CLSID_DivX__U : TGUID = '{31585644-0000-0010-8000-00aa00389b71}';
  75. // dx50
  76. CLSID_dx50 : TGUID = '{30357864-0000-0010-8000-00aa00389b71}';
  77. // DX50
  78. CLSID_DX50_ : TGUID = '{30355844-0000-0010-8000-00aa00389b71}';
  79. // div6
  80. CLSID_div6 : TGUID = '{36766964-0000-0010-8000-00aa00389b71}';
  81. // DIV6
  82. CLSID_DIV6_ : TGUID = '{36564944-0000-0010-8000-00aa00389b71}';
  83. // div5
  84. CLSID_div5 : TGUID = '{35766964-0000-0010-8000-00aa00389b71}';
  85. // DIV5
  86. CLSID_DIV5_ : TGUID = '{35564944-0000-0010-8000-00aa00389b71}';
  87. // div4
  88. CLSID_div4 : TGUID = '{34766964-0000-0010-8000-00aa00389b71}';
  89. // DIV4
  90. CLSID_DIV4_ : TGUID = '{34564944-0000-0010-8000-00aa00389b71}';
  91. // div3
  92. CLSID_div3 : TGUID = '{33766964-0000-0010-8000-00aa00389b71}';
  93. // DIV3
  94. CLSID_DIV3_ : TGUID = '{33564944-0000-0010-8000-00aa00389b71}';
  95. CLSID_DIVXCodec : TGUID = '{78766964-0000-0010-8000-00aa00389b71}';
  96. IID_IIDivXFilterInterface : TGUID = '{D132EE97-3E38-4030-8B17-59163B30A1F5}';
  97. CLSID_DivXPropertiesPage : TGUID = '{310e42a0-f913-11d4-887c-006008dc5c26}';
  98. type
  99. {$IFDEF VER130}
  100. PPointer = ^Pointer;
  101. {$ENDIF}
  102. { Interface to control the Divx Decoder filter.
  103. TODO: discover the last function ... }
  104. IDivXFilterInterface = interface(IUnknown)
  105. ['{D132EE97-3E38-4030-8B17-59163B30A1F5}']
  106. { OpenDivx }
  107. // current postprocessing level 0..100
  108. function get_PPLevel(out PPLevel: integer): HRESULT; stdcall;
  109. // new postprocessing level 0..100
  110. function put_PPLevel(PPLevel: integer): HRESULT; stdcall;
  111. // Put the default postprocessing = 0
  112. function put_DefaultPPLevel: HRESULT; stdcall;
  113. { DIVX }
  114. function put_MaxDelayAllowed(maxdelayallowed: integer): HRESULT; stdcall;
  115. function put_Brightness(brightness: integer): HRESULT; stdcall;
  116. function put_Contrast(contrast: integer): HRESULT; stdcall;
  117. function put_Saturation(saturation: integer): HRESULT; stdcall;
  118. function get_MaxDelayAllowed(out maxdelayallowed: integer): HRESULT; stdcall;
  119. function get_Brightness(out brightness: integer): HRESULT; stdcall;
  120. function get_Contrast(out contrast: integer): HRESULT; stdcall;
  121. function get_Saturation(out saturation: integer): HRESULT; stdcall;
  122. function put_AspectRatio(x, y: integer): HRESULT; stdcall;
  123. function get_AspectRatio(out x, y: integer): HRESULT; stdcall;
  124. end;
  125. ////////////////////////////////////////////////////////////////////////////////
  126. // Ogg Vorbis
  127. type
  128. TVORBISFORMAT = record
  129. nChannels: WORD;
  130. nSamplesPerSec: Longword;
  131. nMinBitsPerSec: Longword;
  132. nAvgBitsPerSec: Longword;
  133. nMaxBitsPerSec: Longword;
  134. fQuality: Double;
  135. end;
  136. const
  137. // f07e245f-5a1f-4d1e-8bff-dc31d84a55ab
  138. CLSID_OggSplitter: TGUID = '{f07e245f-5a1f-4d1e-8bff-dc31d84a55ab}';
  139. // {078C3DAA-9E58-4d42-9E1C-7C8EE79539C5}
  140. CLSID_OggSplitPropPage: TGUID = '{078C3DAA-9E58-4d42-9E1C-7C8EE79539C5}';
  141. // 8cae96b7-85b1-4605-b23c-17ff5262b296
  142. CLSID_OggMux: TGUID = '{8cae96b7-85b1-4605-b23c-17ff5262b296}';
  143. // {AB97AFC3-D08E-4e2d-98E0-AEE6D4634BA4}
  144. CLSID_OggMuxPropPage: TGUID = '{AB97AFC3-D08E-4e2d-98E0-AEE6D4634BA4}';
  145. // {889EF574-0656-4B52-9091-072E52BB1B80}
  146. CLSID_VorbisEnc: TGUID = '{889EF574-0656-4B52-9091-072E52BB1B80}';
  147. // {c5379125-fd36-4277-a7cd-fab469ef3a2f}
  148. CLSID_VorbisEncPropPage: TGUID = '{c5379125-fd36-4277-a7cd-fab469ef3a2f}';
  149. // 02391f44-2767-4e6a-a484-9b47b506f3a4
  150. CLSID_VorbisDec: TGUID = '{02391f44-2767-4e6a-a484-9b47b506f3a4}';
  151. // 77983549-ffda-4a88-b48f-b924e8d1f01c
  152. CLSID_OggDSAboutPage: TGUID = '{77983549-ffda-4a88-b48f-b924e8d1f01c}';
  153. // {D2855FA9-61A7-4db0-B979-71F297C17A04}
  154. MEDIASUBTYPE_Ogg: TGUID = '{D2855FA9-61A7-4db0-B979-71F297C17A04}';
  155. // cddca2d5-6d75-4f98-840e-737bedd5c63b
  156. MEDIASUBTYPE_Vorbis: TGUID = '{cddca2d5-6d75-4f98-840e-737bedd5c63b}';
  157. // 6bddfa7e-9f22-46a9-ab5e-884eff294d9f
  158. FORMAT_VorbisFormat: TGUID = '{6bddfa7e-9f22-46a9-ab5e-884eff294d9f}';
  159. ////////////////////////////////////////////////////////////////////////////////
  160. // WMF9 Utils
  161. type
  162. TWMPofiles8 = (
  163. wmp_V80_255VideoPDA,
  164. wmp_V80_150VideoPDA,
  165. wmp_V80_28856VideoMBR,
  166. wmp_V80_100768VideoMBR,
  167. wmp_V80_288100VideoMBR,
  168. wmp_V80_288Video,
  169. wmp_V80_56Video,
  170. wmp_V80_100Video,
  171. wmp_V80_256Video,
  172. wmp_V80_384Video,
  173. wmp_V80_768Video,
  174. wmp_V80_700NTSCVideo,
  175. wmp_V80_1400NTSCVideo,
  176. wmp_V80_384PALVideo,
  177. wmp_V80_700PALVideo,
  178. wmp_V80_288MonoAudio,
  179. wmp_V80_288StereoAudio,
  180. wmp_V80_32StereoAudio,
  181. wmp_V80_48StereoAudio,
  182. wmp_V80_64StereoAudio,
  183. wmp_V80_96StereoAudio,
  184. wmp_V80_128StereoAudio,
  185. wmp_V80_288VideoOnly,
  186. wmp_V80_56VideoOnly,
  187. wmp_V80_FAIRVBRVideo,
  188. wmp_V80_HIGHVBRVideo,
  189. wmp_V80_BESTVBRVideo
  190. );
  191. const
  192. WMProfiles8 : array[TWMPofiles8] of TGUID =
  193. ('{FEEDBCDF-3FAC-4c93-AC0D-47941EC72C0B}',
  194. '{AEE16DFA-2C14-4a2f-AD3F-A3034031784F}',
  195. '{D66920C4-C21F-4ec8-A0B4-95CF2BD57FC4}',
  196. '{5BDB5A0E-979E-47d3-9596-73B386392A55}',
  197. '{D8722C69-2419-4b36-B4E0-6E17B60564E5}',
  198. '{3DF678D9-1352-4186-BBF8-74F0C19B6AE2}',
  199. '{254E8A96-2612-405c-8039-F0BF725CED7D}',
  200. '{A2E300B4-C2D4-4fc0-B5DD-ECBD948DC0DF}',
  201. '{BBC75500-33D2-4466-B86B-122B201CC9AE}',
  202. '{29B00C2B-09A9-48bd-AD09-CDAE117D1DA7}',
  203. '{74D01102-E71A-4820-8F0D-13D2EC1E4872}',
  204. '{C8C2985F-E5D9-4538-9E23-9B21BF78F745}',
  205. '{931D1BEE-617A-4bcd-9905-CCD0786683EE}',
  206. '{9227C692-AE62-4f72-A7EA-736062D0E21E}',
  207. '{EC298949-639B-45e2-96FD-4AB32D5919C2}',
  208. '{7EA3126D-E1BA-4716-89AF-F65CEE0C0C67}',
  209. '{7E4CAB5C-35DC-45bb-A7C0-19B28070D0CC}',
  210. '{60907F9F-B352-47e5-B210-0EF1F47E9F9D}',
  211. '{5EE06BE5-492B-480a-8A8F-12F373ECF9D4}',
  212. '{09BB5BC4-3176-457f-8DD6-3CD919123E2D}',
  213. '{1FC81930-61F2-436f-9D33-349F2A1C0F10}',
  214. '{407B9450-8BDC-4ee5-88B8-6F527BD941F2}',
  215. '{8C45B4C7-4AEB-4f78-A5EC-88420B9DADEF}',
  216. '{6E2A6955-81DF-4943-BA50-68A986A708F6}',
  217. '{3510A862-5850-4886-835F-D78EC6A64042}',
  218. '{0F10D9D3-3B04-4fb0-A3D3-88D4AC854ACC}',
  219. '{048439BA-309C-440e-9CB4-3DCCA3756423}');
  220. function ProfileFromGUID(const GUID: TGUID): TWMPofiles8;
  221. ////////////////////////////////////////////////////////////////////////////////
  222. { Frees an object reference and replaces the reference with Nil. (Delphi4 compatibility)}
  223. procedure FreeAndNil(var Obj);
  224. { Enable Graphedit to connect with a filter graph.<br>
  225. The application must register the filter graph instance in the Running Object
  226. Table (ROT). The ROT is a globally accessible look-up table that keeps track
  227. of running objects. Objects are registered in the ROT by moniker. To connect
  228. to the graph, GraphEdit searches the ROT for monikers whose display name matches
  229. a particular format: !FilterGraph X pid Y.<br>
  230. <b>Graph:</b> a graph interface (IGraphBuilder, IFilterGraph, IFilterGraph2).<br>
  231. <b>ID:</b> return the ROT identifier.}
  232. function AddGraphToRot(Graph: IFilterGraph; out ID: integer): HRESULT;
  233. { Disable Graphedit to connect with your filter graph.<br>
  234. <b>ID:</b> identifier provided by the @link(AddGraphToRot) method.}
  235. function RemoveGraphFromRot(ID: integer): HRESULT;
  236. { deprecated, convert a Time code event to TDVD_TimeCode record. }
  237. function IntToTimeCode(x : longint): TDVDTimeCode;
  238. { Return a string explaining a filter graph event. }
  239. function GetEventCodeDef(code: longint): string;
  240. { General purpose function to delete a heap allocated TAM_MEDIA_TYPE structure
  241. which is useful when calling IEnumMediaTypes.Next as the interface
  242. implementation allocates the structures which you must later delete
  243. the format block may also be a pointer to an interface to release. }
  244. procedure DeleteMediaType(pmt: PAMMediaType);
  245. { The CreateMediaType function allocates a new AM_MEDIA_TYPE structure,
  246. including the format block. This also comes in useful when using the
  247. IEnumMediaTypes interface so that you can copy a media type, you can do
  248. nearly the same by creating a TMediaType class but as soon as it goes out
  249. of scope the destructor will delete the memory it allocated
  250. (this takes a copy of the memory). }
  251. function CreateMediaType(pSrc: PAMMediaType): PAMMediaType;
  252. { The CopyMediaType function copies an AM_MEDIA_TYPE structure into another
  253. structure, including the format block. This function allocates the memory
  254. for the format block. If the pmtTarget parameter already contains an allocated
  255. format block, a memory leak will occur. To avoid a memory leak, call
  256. FreeMediaType before calling this function. }
  257. procedure CopyMediaType(pmtTarget: PAMMediaType; pmtSource: PAMMediaType);
  258. { The FreeMediaType function frees the format block in an AM_MEDIA_TYPE structure.
  259. Use this function to free just the format block. To delete the AM_MEDIA_TYPE
  260. structure, call DeleteMediaType. }
  261. procedure FreeMediaType(mt: PAMMediaType);
  262. { The CreateAudioMediaType function initializes a media type from a TWAVEFORMATEX structure.
  263. If the bSetFormat parameter is TRUE, the method allocates the memory for the format
  264. block. If the pmt parameter already contains an allocated format block, a memory
  265. leak will occur. To avoid a memory leak, call FreeMediaType before calling this function.
  266. After the method returns, call FreeMediaType again to free the format block. }
  267. function CreateAudioMediaType(pwfx: PWaveFormatEx; pmt: PAMMediaType; bSetFormat: boolean): HRESULT;
  268. { The FOURCCMap function provides conversion between GUID media subtypes and
  269. old-style FOURCC 32-bit media tags. In the original Microsoft?Windows?
  270. multimedia APIs, media types were tagged with 32-bit values created from
  271. four 8-bit characters and were known as FOURCCs. Microsoft DirectShow?media
  272. types have GUIDs for the subtype, partly because these are simpler to create
  273. (creation of a new FOURCC requires its registration with Microsoft).
  274. Because FOURCCs are unique, a one-to-one mapping has been made possible by
  275. allocating a range of 4,000 million GUIDs representing FOURCCs. This range
  276. is all GUIDs of the form: XXXXXXXX-0000-0010-8000-00AA00389B71. }
  277. function FOURCCMap(Fourcc: Cardinal): TGUID;
  278. { Find the four-character codes wich identifi a codec. }
  279. function GetFOURCC(Fourcc: Cardinal): string;
  280. { Convert a FCC (Four Char Codes) to Cardinal. A FCC identifie a media type.}
  281. function FCC(str: String): Cardinal;
  282. { Create the four-character codes from a Cardinal value. }
  283. function MAKEFOURCC(ch0, ch1, ch2, ch3: char): Cardinal;
  284. { The GetErrorString function retrieves the error message for a given return
  285. code, using the current language setting.}
  286. function GetErrorString(hr: HRESULT): string;
  287. { This function examine a media type and return a short description like GraphEdit. }
  288. function GetMediaTypeDescription(MediaType: PAMMediaType): string;
  289. { Retrieve the Size needed to store a bitmat }
  290. function GetBitmapSize(Header: PBitmapInfoHeader): DWORD;
  291. function GetBitmapSubtype(bmiHeader: PBitmapInfoHeader): TGUID; stdcall;
  292. function GetTrueColorType(bmiHeader: PBitmapInfoHeader): TGUID; stdcall;
  293. function GetDXSDKMediaPath : String;
  294. function CopyScreenToBitmap(Rect : TRect; pData : PByte; pHeader : PBitmapInfo) : HBitmap;
  295. type
  296. { Property pages.<br>See also: @link(ShowFilterPropertyPage), @link:(HaveFilterPropertyPage).}
  297. TPropertyPage = (
  298. ppDefault, // Simple property page.
  299. ppVFWCapDisplay, // Capture Video source dialog box.
  300. ppVFWCapFormat, // Capture Video format dialog box.
  301. ppVFWCapSource, // Capture Video source dialog box.
  302. ppVFWCompConfig, // Compress Configure dialog box.
  303. ppVFWCompAbout // Compress About Dialog box.
  304. );
  305. { Show the property page associated with the Filter.
  306. A property page is one way for a filter to support properties that the user can set.
  307. Many of the filters provided with DirectShow support property pages, they are
  308. intended for debugging purposes, and are not recommended for application use.
  309. In most cases the equivalent functionality is provided through a custom interface
  310. on the filter. An application should control these filters programatically,
  311. rather than expose their property pages to users. }
  312. function ShowFilterPropertyPage(parent: THandle; Filter: IBaseFilter;
  313. PropertyPage: TPropertyPage = ppDefault): HRESULT;
  314. { Return true if the specified property page is provided by the Filter.}
  315. function HaveFilterPropertyPage(Filter: IBaseFilter;
  316. PropertyPage: TPropertyPage = ppDefault): boolean;
  317. { Show the property page associated with the Pin. <br>
  318. <b>See also: </b> @link:(ShowFilterPropertyPage).}
  319. function ShowPinPropertyPage(parent: THandle; Pin: IPin): HRESULT;
  320. { Convert 100 nano sec unit to milisecondes. }
  321. function RefTimeToMiliSec(RefTime: Int64): Cardinal;
  322. { Convert milisecondes to 100 nano sec unit}
  323. function MiliSecToRefTime(Milisec: int64): Int64;
  324. { The mechanism for describing a bitmap format is with the BITMAPINFOHEADER
  325. This is really messy to deal with because it invariably has fields that
  326. follow it holding bit fields, palettes and the rest. This function gives
  327. the number of bytes required to hold a VIDEOINFO that represents it. This
  328. count includes the prefix information (like the rcSource rectangle) the
  329. BITMAPINFOHEADER field, and any other colour information on the end.
  330. WARNING If you want to copy a BITMAPINFOHEADER into a VIDEOINFO always make
  331. sure that you use the HEADER macro because the BITMAPINFOHEADER field isn't
  332. right at the start of the VIDEOINFO (there are a number of other fields),
  333. CopyMemory(HEADER(pVideoInfo),pbmi,sizeof(BITMAPINFOHEADER)); }
  334. function GetBitmapFormatSize(const Header: TBitmapInfoHeader): Integer;
  335. { Retrieve original source rectangle from a TAM_Media_type record.}
  336. function GetSourceRectFromMediaType(const MediaType: TAMMediaType): TRect;
  337. { TODO -oMichael Andersen: make documentation }
  338. function StretchRect(R, IR: TRect): TRect;
  339. // raise @link(EDirectShowException) exception if failed.
  340. function CheckDSError(HR: HRESULT): HRESULT;
  341. // milenko start (added functions from dshowutil.cpp)
  342. function FindRenderer(pGB: IGraphBuilder; const mediatype: PGUID; out ppFilter: IBaseFilter): HRESULT;
  343. function FindAudioRenderer(pGB: IGraphBuilder; out ppFilter: IBaseFilter): HRESULT;
  344. function FindVideoRenderer(pGB: IGraphBuilder; out ppFilter: IBaseFilter): HRESULT;
  345. function CountFilterPins(pFilter: IBaseFilter; out pulInPins: Cardinal; out pulOutPins: Cardinal): HRESULT;
  346. function CountTotalFilterPins(pFilter: IBaseFilter; out pulPins: Cardinal): HRESULT;
  347. function GetPin(pFilter: IBaseFilter; dirrequired: TPinDirection; iNum: integer; out ppPin: IPin): HRESULT;
  348. function GetInPin(pFilter: IBaseFilter; nPin: integer): IPin;
  349. function GetOutPin(pFilter: IBaseFilter; nPin: integer): IPin;
  350. function FindOtherSplitterPin(pPinIn: IPin; guid: TGUID; nStream: integer; out ppSplitPin: IPin): HRESULT;
  351. function SeekNextFrame(pSeeking: IMediaSeeking; FPS: Double; Frame: LongInt): HRESULT;
  352. procedure ShowFilenameByCLSID(clsid: TGUID; out szFilename: WideString);
  353. function GetFileDurationString(pMS: IMediaSeeking; out szDuration: WideString): HRESULT;
  354. function CanFrameStep(pGB: IGraphBuilder): Boolean;
  355. procedure UtilFreeMediaType(pmt: PAMMediaType);
  356. procedure UtilDeleteMediaType(pmt: PAMMediaType);
  357. function SaveGraphFile(pGraph: IGraphBuilder; wszPath: WideString): HRESULT;
  358. function LoadGraphFile(pGraph: IGraphBuilder; const wszName: WideString): HRESULT;
  359. // milenko end
  360. // Added by Michael. Used to Detect installed DirectX Version. (Source from getdxver.cpp)
  361. function GetDXVersion(var pdwDirectXVersion : DWORD; out strDirectXVersion : String) : HResult;
  362. type
  363. // DirectShow Exception class
  364. EDirectShowException = class(Exception)
  365. ErrorCode: Integer;
  366. end;
  367. EDSPackException = class(Exception)
  368. ErrorCode: Integer;
  369. end;
  370. // *****************************************************************************
  371. // TSysDevEnum
  372. // *****************************************************************************
  373. {@exclude}
  374. PFilCatNode = ^TFilCatNode;
  375. {@exclude}
  376. TFilCatNode = record
  377. FriendlyName : Shortstring;
  378. CLSID : TGUID;
  379. end;
  380. { Usefull class to enumerate availables filters.
  381. See "Filter Enumerator" sample. }
  382. TSysDevEnum = class
  383. private
  384. FGUID : TGUID;
  385. FCategories : TList;
  386. FFilters : TList;
  387. ACategory : PFilCatNode;
  388. procedure GetCat(catlist: TList; CatGUID: TGUID);
  389. function GetCountCategories: integer;
  390. function GetCountFilters: integer;
  391. function GetCategory(item: integer): TFilCatNode;
  392. function GetFilter(item: integer): TFilCatNode;
  393. public
  394. { Select the main category by GUID. For example CLSID_VideoCompressorCategory
  395. to enumerate Video Compressors. }
  396. procedure SelectGUIDCategory(GUID: TGUID);
  397. { Select the main category by Index. }
  398. procedure SelectIndexCategory(index: integer);
  399. { Call CountCategories to retrieve categories count.}
  400. property CountCategories: integer read GetCountCategories;
  401. { Call CountFilters to retrieve the number of Filte within a Category. }
  402. property CountFilters: integer read GetCountFilters;
  403. { Call Categories to read Category Name and GUID. }
  404. property Categories[item: integer]: TFilCatNode read GetCategory;
  405. { Call Filters to read Filter Name and GUID. }
  406. property Filters[item: integer]: TFilCatNode read GetFilter;
  407. { Find filter index by FriendlyName; -1, if not found }
  408. function FilterIndexOfFriendlyName(const FriendlyName: string): Integer;
  409. { Call GetBaseFilter to retrieve the IBaseFilter interface corresponding to index. }
  410. function GetBaseFilter(index: integer): IBaseFilter; overload;
  411. { Call GetBaseFilter to retrieve the IBaseFilter interface corresponding to GUID. }
  412. function GetBaseFilter(GUID: TGUID): IBaseFilter; overload;
  413. { Call GetMoniker to retrieve the IMoniker interface corresponding to index.
  414. This interface can be used to store a filter with the @link(TBaseFiter) class. }
  415. function GetMoniker(index: integer): IMoniker;
  416. { constructor }
  417. constructor Create; overload;
  418. { constructor. Create the class and initialize the main category with the GUID. }
  419. constructor Create(guid: TGUID); overload;
  420. { destructor }
  421. destructor Destroy; override;
  422. end;
  423. // *****************************************************************************
  424. // TFilterList
  425. // *****************************************************************************
  426. { This class can enumerate all filters in a FilterGraph. }
  427. TFilterList = class(TInterfaceList)
  428. private
  429. Graph : IFilterGraph;
  430. function GetFilter(Index: Integer): IBaseFilter;
  431. procedure PutFilter(Index: Integer; Item: IBaseFilter);
  432. function GetFilterInfo(index: integer): TFilterInfo;
  433. public
  434. { Create a list based on a FilterGraph. }
  435. constructor Create(FilterGraph: IFilterGraph); overload;
  436. { Destructor. }
  437. destructor Destroy; override;
  438. { Update the list. }
  439. procedure Update;
  440. { Reload the list from another FilterGraph.}
  441. procedure Assign(FilterGraph: IFilterGraph);
  442. { Call First to obtain the first interface in the list. }
  443. function First: IBaseFilter;
  444. { Call IndexOf to obtain the index of an interface. }
  445. function IndexOf(Item: IBaseFilter): Integer;
  446. { Call Add to add an interface to the list. }
  447. function Add(Item: IBaseFilter): Integer;
  448. { Call Insert to insert an interface into the list. Item is the interface to
  449. insert, and Index indicates the position (zero-offset) where the interface
  450. should be added. }
  451. procedure Insert(Index: Integer; Item: IBaseFilter);
  452. { Call Last to obtain the last interface in the list. }
  453. function Last: IBaseFilter;
  454. { Call Remove to remove an interface from the list. Remove returns the index
  455. of the removed interface, or ? if the interface was not found. }
  456. function Remove(Item: IBaseFilter): Integer;
  457. { Use Items to directly access an interface in the list. Index identifies each
  458. interface by its position in the list. }
  459. property Items[Index: Integer]: IBaseFilter read GetFilter write PutFilter; default;
  460. { call FilterInfo to retrieve the Filer name and his FilterGraph. }
  461. property FilterInfo[Index: Integer] : TFilterInfo read GetFilterInfo;
  462. end;
  463. //******************************************************************************
  464. // TPinList
  465. //******************************************************************************
  466. {Helper class to enumerate pins on a filter. }
  467. TPinList = class(TInterfaceList)
  468. private
  469. Filter: IBaseFilter;
  470. function GetPin(Index: Integer): IPin;
  471. procedure PutPin(Index: Integer; Item: IPin);
  472. function GetPinInfo(index: integer): TPinInfo;
  473. function GetConnected(Index: Integer): boolean;
  474. public
  475. { Create a Pin list from the IBaseFilter interface. }
  476. constructor Create(BaseFilter: IBaseFilter); overload;
  477. { Destructor. }
  478. destructor Destroy; override;
  479. { Update the Pin list. }
  480. procedure Update;
  481. { Load a Pin list from the IBaseFilter Interface. }
  482. procedure Assign(BaseFilter: IBaseFilter);
  483. { Return the First Pin from in the list. }
  484. function First: IPin;
  485. { Return the index of Pin in the list. }
  486. function IndexOf(Item: IPin): Integer;
  487. { Add A Pin to the list. }
  488. function Add(Item: IPin): Integer;
  489. { Insert a pin at the given position. }
  490. procedure Insert(Index: Integer; Item: IPin);
  491. { Return the last pin in the list. }
  492. function Last: IPin;
  493. { Remove a pin from the lis. }
  494. function Remove(Item: IPin): Integer;
  495. { Return the the pin interface at the defined position. }
  496. property Items[Index: Integer]: IPin read GetPin write PutPin; default;
  497. { Retrieve informations on a pin. }
  498. property PinInfo[Index: Integer]: TPinInfo read GetPinInfo;
  499. property Connected[Index: Integer]: boolean read GetConnected;
  500. end;
  501. // *****************************************************************************
  502. // TMediaType
  503. // *****************************************************************************
  504. { Uses TMediaType to configure media types. This class have a special property editor.
  505. See @link(TSampleGrabber)}
  506. TMediaType = class(TPersistent)
  507. private
  508. function GetMajorType: TGUID;
  509. procedure SetMajorType(MT: TGUID);
  510. function GetSubType: TGUID;
  511. procedure SetSubType(ST: TGUID);
  512. procedure SetFormatType(const GUID: TGUID);
  513. function GetFormatType: TGUID;
  514. procedure ReadData(Stream: TStream);
  515. procedure WriteData(Stream: TStream);
  516. protected
  517. { @exclude}
  518. procedure DefineProperties(Filer: TFiler); override;
  519. public
  520. { Local copy of the Media Type. }
  521. AMMediaType: PAMMediaType;
  522. { Destructor method. }
  523. destructor Destroy; override;
  524. { Constructor method. }
  525. constructor Create; overload;
  526. { Constructor method. Initialised with majortype. }
  527. constructor Create(majortype: TGUID); overload;
  528. { Constructor method. Initialised with another media type. }
  529. constructor Create(mediatype: PAMMediaType); overload;
  530. { Constructor method. Initialised with another TMediaType}
  531. constructor Create(MTClass: TMediaType); overload;
  532. { Copy from another TMediaType. }
  533. procedure Assign(Source: TPersistent); override;
  534. { Copy from another PAM_MEDIA_TYPE. }
  535. procedure Read(mediatype: PAMMediaType);
  536. { Tests for equality between TMediaType objects.<br>
  537. <b>rt:</b> Reference to the TMediaType object to compare.<br>
  538. Returns TRUE if rt is equal to this object. Otherwise, returns FALSE. }
  539. function Equal(MTClass: TMediaType): boolean; overload;
  540. { Tests for inequality between TMediaType objects.<br>
  541. <b>rt:</b> Reference to the TMediaType object to compare.<br>
  542. Returns TRUE if rt is not equal to this object. Otherwise, returns FALSE. }
  543. function NotEqual(MTClass: TMediaType): boolean; overload;
  544. { The IsValid method determines whether a major type has been assigned to this object.
  545. Returns TRUE if a major type has been assigned to this object. Otherwise, returns FALSE.
  546. By default, TMediaType objects are initialized with a major type of GUID_NULL.
  547. Call this method to determine whether the object has been correctly initialized.}
  548. function IsValid: boolean;
  549. { The IsFixedSize method determines if the samples have a fixed size or a variable size.
  550. Returns the value of the bFixedSizeSamples member.}
  551. function IsFixedSize: boolean;
  552. { The IsTemporalCompressed method determines if the stream uses temporal compression.
  553. Returns the value of the bTemporalCompression member. }
  554. function IsTemporalCompressed: boolean;
  555. { The GetSampleSize method retrieves the sample size.
  556. If the sample size is fixed, returns the sample size in bytes. Otherwise,
  557. returns zero. }
  558. function GetSampleSize: ULONG;
  559. { The SetSampleSize method specifies a fixed sample size, or specifies that
  560. samples have a variable size. If value of sz is zero, the media type uses
  561. variable sample sizes. Otherwise, the sample size is fixed at sz bytes. }
  562. procedure SetSampleSize(SZ: ULONG);
  563. { The SetVariableSize method specifies that samples do not have a fixed size.
  564. This method sets the bFixedSizeSamples member to FALSE. Subsequent calls to the TMediaType.GetSampleSize method return zero. }
  565. procedure SetVariableSize;
  566. { The SetTemporalCompression method specifies whether samples are compressed
  567. using temporal (interframe) compression. }
  568. procedure SetTemporalCompression(bCompressed: boolean);
  569. { read/write pointer to format - can't change length without
  570. calling SetFormat, AllocFormatBuffer or ReallocFormatBuffer}
  571. function Format: pointer;
  572. { The FormatLength method retrieves the length of the format block. }
  573. function FormatLength: ULONG;
  574. { The SetFormat method specifies the format block.<br>
  575. <b>pFormat:</b> Pointer to a block of memory that contains the format block.<br>
  576. <b>length:</b> Length of the format block, in bytes. }
  577. function SetFormat(pFormat: pointer; length: ULONG): boolean;
  578. { The ResetFormatBuffer method deletes the format block. }
  579. procedure ResetFormatBuffer;
  580. { The AllocFormatBuffer method allocates memory for the format block.<br>
  581. <b>length:</b> Size required for the format block, in bytes.<br>
  582. Returns a pointer to the new block if successful. Otherwise, returns nil.<br>
  583. If the method successfully allocates a new format block, it frees the existing
  584. format block. If the allocation fails, the method leaves the existing format block. }
  585. function AllocFormatBuffer(length: ULONG): pointer;
  586. { The ReallocFormatBuffer method reallocates the format block to a new size.<br>
  587. <b>length:</b> New size required for the format block, in bytes. Must be greater
  588. than zero.<br>
  589. Returns a pointer to the new block if successful. Otherwise, returns either
  590. a pointer to the old format block, or nil.
  591. This method allocates a new format block. It copies as much of the existing
  592. format block as possible into the new format block. If the new block is
  593. smaller than the existing block, the existing format block is truncated.
  594. If the new block is larger, the contents of the additional space are undefined.
  595. They are not explicitly set to zero. }
  596. function ReallocFormatBuffer(length: ULONG): pointer;
  597. { The InitMediaType method initializes the media type.
  598. This method zeroes the object's memory, sets the fixed-sample-size property
  599. to TRUE, and sets the sample size to 1. }
  600. procedure InitMediaType;
  601. { The MatchesPartial method determines if this media type matches a partially
  602. specified media type. The media type specified by ppartial can have a value
  603. of GUID_NULL for the major type, subtype, or format type. Any members with
  604. GUID_NULL values are not tested. (In effect, GUID_NULL acts as a wildcard.)
  605. Members with values other than GUID_NULL must match for the media type to match.}
  606. function MatchesPartial(ppartial: TMediaType): boolean;
  607. { The IsPartiallySpecified method determines if the media type is partially
  608. defined. A media type is partial if the major type, subtype, or format type
  609. is GUID_NULL. The IPin.Connect method can accept partial media types.
  610. The implementation does not actually test the subtype. If there is a specified
  611. format type, the media type is not considered partial, even if the subtype is GUID_NULL. }
  612. function IsPartiallySpecified: boolean;
  613. { Set or retrieve the MajorType GUID. }
  614. property MajorType: TGUID read GetMajorType write SetMajorType;
  615. { Set or retrieve the SubType GUID. }
  616. property SubType: TGUID read GetSubType write SetSubType;
  617. { Set or retrieve the FormatType GUID. }
  618. property FormatType: TGUID read GetFormatType write SetFormatType;
  619. end;
  620. // *****************************************************************************
  621. // TEnumMediaType
  622. // *****************************************************************************
  623. { This class can retrieve all media types from a pin, a file or an IEnumMediaTypes interface. }
  624. TEnumMediaType = class(TObject)
  625. private
  626. FList : TList;
  627. function GetItem(Index: Integer): TMediaType;
  628. procedure SetItem(Index: Integer; Item: TMediaType);
  629. function GetMediaDescription(Index: Integer): string;
  630. function GetCount: integer;
  631. public
  632. { Constructor method.}
  633. constructor Create; overload;
  634. { Constructor method enumerating all media types on a pin. }
  635. constructor Create(Pin: IPin); overload;
  636. { Constructor method enumerating media types provided by a IEnumMediaType interface. }
  637. constructor Create(EnumMT: IEnumMediaTypes); overload;
  638. { Constructor method enumerating all media types availables in a media file.
  639. Support WMF files. }
  640. constructor Create(FileName: TFileName); overload;
  641. { Destructor method. }
  642. destructor Destroy; override;
  643. { Enumerate all media types on a pin.}
  644. procedure Assign(Pin: IPin); overload;
  645. { Enumerate media types provided by a IEnumMediaType interface. }
  646. procedure Assign(EnumMT: IEnumMediaTypes); overload;
  647. { Enumerate all media types availables in a media file. Support WMF files. }
  648. procedure Assign(FileName: TFileName); overload;
  649. { Add a media type to the list. }
  650. function Add(Item: TMediaType): Integer;
  651. { Clear the list. }
  652. procedure Clear;
  653. { Remove a media type from the list. }
  654. procedure Delete(Index: Integer);
  655. { Retrieve a mediaa type. }
  656. property Items[Index: Integer]: TMediaType read GetItem write SetItem;
  657. { Return a string describing the media type. }
  658. property MediaDescription[Index: Integer]: string read GetMediaDescription;
  659. { Number of items in the list. }
  660. property Count: integer read GetCount;
  661. end;
  662. // *****************************************************************************
  663. // TPersistentMemory
  664. // *****************************************************************************
  665. { For internal use. This class is designed to store a custom memory stream with
  666. a form. It is the ancestor of @link(TBaseFilter).}
  667. TPersistentMemory = class(TPersistent)
  668. private
  669. FData: pointer;
  670. FDataLength: Cardinal;
  671. procedure ReadData(Stream: TStream);
  672. procedure WriteData(Stream: TStream);
  673. function Equal(Memory: TPersistentMemory): boolean;
  674. procedure AllocateMemory(ALength: Cardinal);
  675. protected
  676. { @exclude }
  677. procedure AssignTo(Dest: TPersistent); override;
  678. { @exclude }
  679. procedure DefineProperties(Filer: TFiler); override;
  680. public
  681. { Set/Get the buffer length. }
  682. property DataLength: Cardinal read FDataLength write AllocateMemory;
  683. { Pointer to buffer. }
  684. property Data: Pointer read FData;
  685. { Constructor }
  686. constructor Create; virtual;
  687. { Destructor }
  688. destructor Destroy; override;
  689. { Call Assign to copy the properties or other attributes of one object from another. }
  690. procedure Assign(Source: TPersistent); override;
  691. end;
  692. // *****************************************************************************
  693. // TBaseFilter
  694. // *****************************************************************************
  695. { This class can store a custom filter as a moniker within the dfm file. }
  696. TBaseFilter = class(TPersistentMemory)
  697. private
  698. procedure SetMoniker(Moniker: IMoniker);
  699. function GetMoniker: IMoniker;
  700. public
  701. { Set or retrieve the moniker interface.}
  702. property Moniker: IMoniker read GetMoniker write SetMoniker;
  703. { Read a property bag. For example you can read the GUID identifier (PropertyBag('CLSID'))}
  704. function PropertyBag(Name: WideString): OleVariant;
  705. {Return the IBaseFilter interface corresponding to filter.}
  706. function CreateFilter: IBaseFilter;
  707. end;
  708. // *****************************************************************************
  709. // DxDiag.h
  710. // *****************************************************************************
  711. const
  712. // This identifier is passed to IDxDiagProvider::Initialize in order to ensure that an
  713. // application was built against the correct header files. This number is
  714. // incremented whenever a header (or other) change would require applications
  715. // to be rebuilt. If the version doesn't match, IDxDiagProvider::Initialize will fail.
  716. // (The number itself has no meaning.)
  717. DXDIAG_DX9_SDK_VERSION = 111;
  718. (****************************************************************************
  719. *
  720. * DxDiag Errors
  721. *
  722. ****************************************************************************)
  723. DXDIAG_E_INSUFFICIENT_BUFFER = HResult($8007007A);
  724. (****************************************************************************
  725. *
  726. * DxDiag CLSIDs
  727. *
  728. ****************************************************************************)
  729. CLSID_DxDiagProvider : TGUID = '{A65B8071-3BFE-4213-9A5B-491DA4461CA7}';
  730. (****************************************************************************
  731. *
  732. * DxDiag Interface IIDs
  733. *
  734. ****************************************************************************)
  735. IID_IDxDiagProvider : TGUID = '{9C6B4CB0-23F8-49CC-A3ED-45A55000A6D2}';
  736. IID_IDxDiagContainer : TGUID = '{7D0F462F-4064-4862-BC7F-933E5058C10F}';
  737. Type
  738. (****************************************************************************
  739. *
  740. * DxDiag Structures
  741. *
  742. ****************************************************************************)
  743. PDXDIAG_INIT_PARAMS = ^TDxDiagInitParams;
  744. _DXDIAG_INIT_PARAMS = record
  745. dwSize : DWORD; // Size of this structure.
  746. dwDxDiagHeaderVersion : DWORD; // Pass in DXDIAG_DX9_SDK_VERSION. This verifies
  747. // the header and dll are correctly matched.
  748. bAllowWHQLChecks : Boolean; // If true, allow dxdiag to check if drivers are
  749. // digital signed as logo'd by WHQL which may
  750. // connect via internet to update WHQL certificates.
  751. pReserved : Pointer; // Reserved. Must be NULL.
  752. End;
  753. {$EXTERNALSYM _DXDIAG_INIT_PARAMS}
  754. DXDIAG_INIT_PARAMS = _DXDIAG_INIT_PARAMS;
  755. {$EXTERNALSYM DXDIAG_INIT_PARAMS}
  756. TDxDiagInitParams = _DXDIAG_INIT_PARAMS;
  757. (****************************************************************************
  758. *
  759. * DxDiag Application Interfaces
  760. *
  761. ****************************************************************************)
  762. IDxDiagProvider = interface;
  763. IDxDiagContainer = interface;
  764. IDxDiagProvider = interface(IUnknown)
  765. ['{9C6B4CB0-23F8-49CC-A3ED-45A55000A6D2}']
  766. // *** IDxDiagProvider methods *** //
  767. function Initialize(pParams : PDXDIAG_INIT_PARAMS): HResult; stdcall;
  768. function GetRootContainer(Out ppInstance : IDxDiagContainer): HResult; stdcall;
  769. End;
  770. IDxDiagContainer = interface(IUnknown)
  771. ['{7D0F462F-4064-4862-BC7F-933E5058C10F}']
  772. // *** IDxDiagContainer methods *** //
  773. function GetNumberOfChildContainers(Out pdwCount : dword) : HResult; stdcall;
  774. function EnumChildContainerNames(dwIndex : dword; pwszContainer : PWideChar; cchContainer : DWord) : HResult; stdcall;
  775. function GetChildContainer(pwszContainer : PWideChar; Out ppInstance : IDxDiagContainer) : Hresult; stdcall;
  776. function GetNumberOfProps(Out pdwCount : dword) : HResult; stdcall;
  777. function EnumPropNames(dwIndex : dword; pwszPropName : PWideChar; cchPropName : dword) : HResult; stdcall;
  778. function GetProp(pwszPropName : PWideChar; Out pvarProp : OleVariant) : HResult; stdcall;
  779. End;
  780. // milenko start DMO TMediaBuffer implementation
  781. TMediaBuffer = class(TObject, IMediaBuffer, IUnKnown)
  782. private
  783. FRefCount: integer;
  784. FLength: DWORD;
  785. FMaxLength: DWORD;
  786. FData: PByte;
  787. public
  788. constructor Create(MaxLen: DWORD);
  789. destructor Destroy; override;
  790. class function CreateBuffer(MaxLen: DWORD; const IID: TGUID; out Obj): HRESULT;
  791. // IUnknown
  792. function QueryInterface(const IID: TGUID; out Obj): HResult; stdcall;
  793. function _AddRef: Integer; stdcall;
  794. function _Release: Integer; stdcall;
  795. // IMediaBuffer methods
  796. function SetLength(cbLength: DWORD): HResult; stdcall;
  797. function GetMaxLength(out pcbMaxLength: DWORD): HResult; stdcall;
  798. function GetBufferAndLength(out ppBuffer: PByte; // not filled if NULL
  799. out pcbLength: DWORD // not filled if NULL
  800. ): HResult; stdcall;
  801. end;
  802. // milenko end
  803. // milenko start wxutil implementation
  804. const
  805. RESOLUTION = DWORD(1); // High resolution timer
  806. ADVISE_CACHE = integer(4); // Default cache size
  807. MILLISECONDS = LONGLONG(1000); // 10 ^ 3
  808. NANOSECONDS = LONGLONG(1000000000); // 10 ^ 9
  809. UNITS = LONGLONG(NANOSECONDS div 100); // 10 ^ 7
  810. TimeZero = LONGLONG(0);
  811. type
  812. DWORDLONG = LONGLONG; // Should be unsigned Int64 !!!
  813. ULONGLONG = DWORDLONG; // Should be unsigned Int64 !!!
  814. function UInt32x32To64(a, b: DWORD): ULONGLONG;
  815. function Int64x32Div32(a: LONGLONG; b, c, d: LongInt): LONGLONG;
  816. function Int32x32To64(a, b: integer): Int64;
  817. function MILLISECONDS_TO_100NS_UNITS(Ms: LONGLONG): LONGLONG;
  818. function llMulDiv(a, b, c, d: LONGLONG): LONGLONG;
  819. function AmGetLastErrorToHResult: HRESULT;
  820. function IsEqualObject(pFirst, pSecond: IUnknown): Boolean;
  821. // milenko end
  822. // milenko start namedguid implementation
  823. const
  824. IID_IDirectDrawKernel : TGUID = '{8D56C120-6A08-11D0-9B06-00A0C903A3B8}';
  825. IID_IDirectDrawSurfaceKernel: TGUID = '{60755DA0-6A40-11D0-9B06-00A0C903A3B8}';
  826. function GetGUIDString(GUID: TGUID): String;
  827. // milenko end
  828. // milenko start (usefull functions to get linear amplification)
  829. function GetBasicAudioVolume(Value : integer) : integer;
  830. function SetBasicAudioVolume(Value : integer) : integer;
  831. function GetBasicAudioPan(Value : integer) : integer;
  832. function SetBasicAudioPan(Value : integer) : integer;
  833. // milenko end
  834. // milenok start (yet another delphi5 compatibility ...)
  835. {$IFDEF VER130}
  836. function GUIDToString(const GUID: TGUID): string;
  837. function StringToGUID(const S: string): TGUID;
  838. function EnsureRange(const AValue, AMin, AMax: Integer): Integer;
  839. {$ENDIF}
  840. // milenko end
  841. {$IFNDEF COMPILER6_UP}
  842. procedure Set8087CW(NewCW: Word);
  843. function Get8087CW: Word;
  844. {$ENDIF}
  845. // previously TMPEGHeaderBitsWrapper
  846. function MPEGHeaderBitsGetSectionLength(Header: PMPEGHeaderBits) : Word;
  847. function MPEGHeaderBitsGetReserved(Header: PMPEGHeaderBits): WORD;
  848. function MPEGHeaderBitsGetPrivateIndicator(Header: PMPEGHeaderBits): WORD;
  849. function MPEGHeaderBitsGetSectionSyntaxIndicator(Header: PMPEGHeaderBits): WORD;
  850. procedure MPEGHeaderBitsSetSectionLength(Header: PMPEGHeaderBits; AValue: WORD);
  851. procedure MPEGHeaderBitsSetReserved(Header: PMPEGHeaderBits; AValue: WORD);
  852. procedure MPEGHeaderBitsSetPrivateIndicator(Header: PMPEGHeaderBits; AValue: WORD);
  853. procedure MPEGHeaderBitsSetSectionSyntaxIndicator(Header: PMPEGHeaderBits; AValue: WORD);
  854. // previously TPIDBitsWrapper
  855. function PIDBitsGetReserved(PIDBits: PPIDBits): WORD;
  856. function PIDBitsGetProgramId(PIDBits: PPIDBits): WORD;
  857. procedure PIDBitsSetReserved(PIDBits: PPIDBits; AValue: WORD);
  858. procedure PIDBitsSetProgramId(PIDBits: PPIDBits; AValue: WORD);
  859. // previously TPIDBitsWrapper
  860. function MPEGHeaderVersionBitsGetCurrentNextIndicator(MPEGHeaderVersionBits: PMPEGHeaderVersionBits): Byte;
  861. function MPEGHeaderVersionBitsGetVersionNumber(MPEGHeaderVersionBits: PMPEGHeaderVersionBits): Byte;
  862. function MPEGHeaderVersionBitsGetReserved(MPEGHeaderVersionBits: PMPEGHeaderVersionBits): Byte;
  863. procedure MPEGHeaderVersionBitsSetCurrentNextIndicator(MPEGHeaderVersionBits: PMPEGHeaderVersionBits; AValue: Byte);
  864. procedure MPEGHeaderVersionBitsSetVersionNumber(MPEGHeaderVersionBits: PMPEGHeaderVersionBits; AValue: Byte);
  865. procedure MPEGHeaderVersionBitsSetReserved(MPEGHeaderVersionBits: PMPEGHeaderVersionBits; AValue: Byte);
  866. implementation
  867. uses
  868. DirectSound, Math, ComObj, Registry;
  869. {$IFNDEF COMPILER6_UP}
  870. var
  871. Default8087CW: Word = $1372;
  872. procedure Set8087CW(NewCW: Word);
  873. begin
  874. Default8087CW := NewCW;
  875. asm
  876. FNCLEX
  877. FLDCW Default8087CW
  878. end;
  879. end;
  880. function Get8087CW: Word;
  881. asm
  882. PUSH 0
  883. FNSTCW [ESP].Word
  884. POP EAX
  885. end;
  886. {$ENDIF}
  887. function ProfileFromGUID(const GUID: TGUID): TWMPofiles8;
  888. begin
  889. for result := low(TWMPofiles8) to high(TWMPofiles8) do
  890. if IsEqualGUID(GUID, WMProfiles8[result]) then Exit;
  891. Result := TWMPofiles8(-1);
  892. end;
  893. //----------------------------------------------------------------------------
  894. // Retrieve the Size needed to store a bitmat
  895. //----------------------------------------------------------------------------
  896. function GetBitmapSize(Header: PBitmapInfoHeader): DWORD;
  897. function WIDTHBYTES(bits: DWORD): DWORD;
  898. begin
  899. result := DWORD((bits+31) and (not 31)) div 8;
  900. end;
  901. function DIBWIDTHBYTES(bi: PBITMAPINFOHEADER): DWORD;
  902. begin
  903. result := DWORD(WIDTHBYTES(DWORD(bi.biWidth) * DWORD(bi.biBitCount)));
  904. end;
  905. function _DIBSIZE(bi: PBITMAPINFOHEADER): DWORD;
  906. begin
  907. result := DIBWIDTHBYTES(bi) * DWORD(bi.biHeight);
  908. end;
  909. begin
  910. if (Header.biHeight < 0) then result := -1 * _DIBSIZE(Header)
  911. else result := _DIBSIZE(Header);
  912. end;
  913. // This is called if the header has a 16 bit colour depth and needs to work
  914. // out the detailed type from the bit fields (either RGB 565 or RGB 555)
  915. function GetTrueColorType(bmiHeader: PBitmapInfoHeader): TGUID; stdcall;
  916. var
  917. bmInfo: PBitmapInfo;
  918. begin
  919. bmInfo := PBitmapInfo(bmiHeader);
  920. ASSERT(bmiHeader.biBitCount = 16);
  921. // If its BI_RGB then it's RGB 555 by default
  922. if (bmiHeader.biCompression = BI_RGB) then
  923. begin
  924. Result := MEDIASUBTYPE_RGB555;
  925. Exit;
  926. end;
  927. if CompareMem(@bmInfo.bmiColors, @bits555, SizeOf(bits555)) then
  928. Result := MEDIASUBTYPE_RGB555 else
  929. if CompareMem(@bmInfo.bmiColors, @bits565, SizeOf(bits565)) then
  930. Result := MEDIASUBTYPE_RGB565 else
  931. Result := GUID_NULL;
  932. end;
  933. // Given a BITMAPINFOHEADER structure this returns the GUID sub type that is
  934. // used to describe it in format negotiations. For example a video codec fills
  935. // in the format block with a VIDEOINFO structure, it also fills in the major
  936. // type with MEDIATYPE_VIDEO and the subtype with a GUID that matches the bit
  937. // count, for example if it is an eight bit image then MEDIASUBTYPE_RGB8
  938. function GetBitmapSubtype(bmiHeader: PBitmapInfoHeader): TGUID; stdcall;
  939. begin
  940. ASSERT(bmiHeader <> nil);
  941. // If it's not RGB then create a GUID from the compression type
  942. if (bmiHeader.biCompression <> BI_RGB) then
  943. if (bmiHeader.biCompression <> BI_BITFIELDS) then
  944. begin
  945. Result := FourCCMap(bmiHeader.biCompression);
  946. Exit;
  947. end;
  948. // Map the RGB DIB bit depth to a image GUID
  949. case (bmiHeader.biBitCount) of
  950. 1 : result := MEDIASUBTYPE_RGB1;
  951. 4 : result := MEDIASUBTYPE_RGB4;
  952. 8 : result := MEDIASUBTYPE_RGB8;
  953. 16 : result := GetTrueColorType(bmiHeader);
  954. 24 : result := MEDIASUBTYPE_RGB24;
  955. 32 : result := MEDIASUBTYPE_RGB32;
  956. else
  957. result := GUID_NULL;
  958. end;
  959. end;
  960. //----------------------------------------------------------------------------
  961. // Frees an object reference and replaces the reference with Nil.
  962. //----------------------------------------------------------------------------
  963. procedure FreeAndNil(var Obj);
  964. var
  965. Temp: TObject;
  966. begin
  967. Temp := TObject(Obj);
  968. Pointer(Obj) := nil;
  969. Temp.Free;
  970. end;
  971. //----------------------------------------------------------------------------
  972. // Enable Graphedit to connect with your filter graph
  973. //----------------------------------------------------------------------------
  974. function AddGraphToRot(Graph: IFilterGraph; out ID: integer): HRESULT;
  975. var
  976. Moniker: IMoniker;
  977. ROT : IRunningObjectTable;
  978. wsz : WideString;
  979. begin
  980. result := GetRunningObjectTable(0, ROT);
  981. if (result <> S_OK) then exit;
  982. wsz := format('FilterGraph %p pid %x',[pointer(graph),GetCurrentProcessId()]);
  983. result := CreateItemMoniker('!', PWideChar(wsz), Moniker);
  984. if (result <> S_OK) then exit;
  985. result := ROT.Register(0, Graph, Moniker, ID);
  986. Moniker := nil;
  987. end;
  988. //----------------------------------------------------------------------------
  989. // Disable Graphedit to connect with your filter graph
  990. //----------------------------------------------------------------------------
  991. function RemoveGraphFromRot(ID: integer): HRESULT;
  992. var ROT: IRunningObjectTable;
  993. begin
  994. result := GetRunningObjectTable(0, ROT);
  995. if (result <> S_OK) then exit;
  996. result := ROT.Revoke(ID);
  997. ROT := nil;
  998. end;
  999. function IntToTimeCode(x : longint): TDVDTimeCode;
  1000. begin
  1001. Result.Hours1 := (x and $F0000000) shr 28;
  1002. Result.Hours10 := (x and $0F000000) shr 24;
  1003. Result.Minutes1 := (x and $00F00000) shr 20;
  1004. Result.Minutes10 := (x and $000F0000) shr 16;
  1005. Result.Seconds1 := (x and $0000F000) shr 12;
  1006. Result.Seconds10 := (x and $00000F00) shr 08;
  1007. Result.Frames1 := (x and $000000F0) shr 04;
  1008. Result.Frames10 := (x and $0000000C) shr 02;
  1009. Result.FrameRateCode := (x and $00000003) shr 00;
  1010. end;
  1011. function GetEventCodeDef(code: longint): string;
  1012. begin
  1013. case code of
  1014. EC_ACTIVATE : result:= 'EC_ACTIVATE - A video window is being activated or deactivated.';
  1015. EC_BUFFERING_DATA : result:= 'EC_BUFFERING_DATA - The graph is buffering data, or has stopped buffering data.';
  1016. EC_CLOCK_CHANGED : result:= 'EC_CLOCK_CHANGED - The reference clock has changed.';
  1017. EC_COMPLETE : result:= 'EC_COMPLETE - All data from a particular stream has been rendered.';
  1018. EC_DEVICE_LOST : result:= 'EC_DEVICE_LOST - A Plug and Play device was removed or has become available again.';
  1019. EC_DISPLAY_CHANGED : result:= 'EC_DISPLAY_CHANGED - The display mode has changed.';
  1020. EC_END_OF_SEGMENT : result:= 'EC_END_OF_SEGMENT - The end of a segment has been reached.';
  1021. EC_ERROR_STILLPLAYING : result:= 'EC_ERROR_STILLPLAYING - An asynchronous command to run the graph has failed.';
  1022. EC_ERRORABORT : result:= 'EC_ERRORABORT - An operation was aborted because of an error.';
  1023. EC_FULLSCREEN_LOST : result:= 'EC_FULLSCREEN_LOST - The video renderer is switching out of full-screen mode.';
  1024. EC_GRAPH_CHANGED : result:= 'EC_GRAPH_CHANGED - The filter graph has changed.';
  1025. EC_NEED_RESTART : result:= 'EC_NEED_RESTART - A filter is requesting that the graph be restarted.';
  1026. EC_NOTIFY_WINDOW : result:= 'EC_NOTIFY_WINDOW - Notifies a filter of the video renderer''s window.';
  1027. EC_OLE_EVENT : result:= 'EC_OLE_EVENT - A filter is passing a text string to the application.';
  1028. EC_OPENING_FILE : result:= 'EC_OPENING_FILE - The graph is opening a file, or has finished opening a file.';
  1029. EC_PALETTE_CHANGED : result:= 'EC_PALETTE_CHANGED - The video palette has changed.';
  1030. EC_PAUSED : result:= 'EC_PAUSED - A pause request has completed.';
  1031. EC_QUALITY_CHANGE : result:= 'EC_QUALITY_CHANGE - The graph is dropping samples, for quality control.';
  1032. EC_REPAINT : result:= 'EC_REPAINT - A video renderer requires a repaint.';
  1033. EC_SEGMENT_STARTED : result:= 'EC_SEGMENT_STARTED - A new segment has started.';
  1034. EC_SHUTTING_DOWN : result:= 'EC_SHUTTING_DOWN - The filter graph is shutting down, prior to being destroyed.';
  1035. EC_SNDDEV_IN_ERROR : result:= 'EC_SNDDEV_IN_ERROR - An audio device error has occurred on an input pin.';
  1036. EC_SNDDEV_OUT_ERROR : result:= 'EC_SNDDEV_OUT_ERROR - An audio device error has occurred on an output pin.';
  1037. EC_STARVATION : result:= 'EC_STARVATION - A filter is not receiving enough data.';
  1038. EC_STEP_COMPLETE : result:= 'EC_STEP_COMPLETE - A filter performing frame stepping has stepped the specified number of frames.';
  1039. EC_STREAM_CONTROL_STARTED : result:= 'EC_STREAM_CONTROL_STARTED - A stream-control start command has taken effect.';
  1040. EC_STREAM_CONTROL_STOPPED : result:= 'EC_STREAM_CONTROL_STOPPED - A stream-control start command has taken effect.';
  1041. EC_STREAM_ERROR_STILLPLAYING : result:= 'EC_STREAM_ERROR_STILLPLAYING - An error has occurred in a stream. The stream is still playing.';
  1042. EC_STREAM_ERROR_STOPPED : result:= 'EC_STREAM_ERROR_STOPPED - A stream has stopped because of an error.';
  1043. EC_USERABORT : result:= 'EC_USERABORT - The user has terminated playback.';
  1044. EC_VIDEO_SIZE_CHANGED : result:= 'EC_VIDEO_SIZE_CHANGED - The native video size has changed.';
  1045. EC_WINDOW_DESTROYED : result:= 'EC_WINDOW_DESTROYED - The video renderer was destroyed or removed from the graph.';
  1046. EC_TIMECODE_AVAILABLE : result:= 'EC_TIMECODE_AVAILABLE- Sent by filter supporting timecode.';
  1047. EC_EXTDEVICE_MODE_CHANGE : result:= 'EC_EXTDEVICE_MODE_CHANGE - Sent by filter supporting IAMExtDevice.';
  1048. EC_CLOCK_UNSET : result:= 'EC_CLOCK_UNSET - notify the filter graph to unset the current graph clock.';
  1049. EC_TIME : result:= 'EC_TIME - The requested reference time occurred (currently not used).';
  1050. EC_VMR_RENDERDEVICE_SET : result:= 'EC_VMR_RENDERDEVICE_SET - Identifies the type of rendering mechanism the VMR is using to display video.';
  1051. EC_DVD_ANGLE_CHANGE : result:= 'EC_DVD_ANGLE_CHANGE - Signals that either the number of available angles changed or that the current angle number changed.';
  1052. EC_DVD_ANGLES_AVAILABLE : result:= 'EC_DVD_ANGLES_AVAILABLE - Indicates whether an angle block is being played and angle changes can be performed.';
  1053. EC_DVD_AUDIO_STREAM_CHANGE : result:= 'EC_DVD_AUDIO_STREAM_CHANGE - Signals that the current audio stream number changed for the main title.';
  1054. EC_DVD_BUTTON_AUTO_ACTIVATED : result:= 'EC_DVD_BUTTON_AUTO_ACTIVATED - Signals that a menu button has been automatically activated per instructions on the disc.';
  1055. EC_DVD_BUTTON_CHANGE : result:= 'EC_DVD_BUTTON_CHANGE - Signals that either the number of available buttons changed or that the currently selected button number changed.';
  1056. EC_DVD_CHAPTER_AUTOSTOP : result:= 'EC_DVD_CHAPTER_AUTOSTOP - Indicates that playback stopped as the result of a call to the IDvdControl2::PlayChaptersAutoStop method.';
  1057. EC_DVD_CHAPTER_START : result:= 'EC_DVD_CHAPTER_START - Signals that the DVD Navigator started playback of a new chapter in the current title.';
  1058. EC_DVD_CMD_START : result:= 'EC_DVD_CMD_START - Signals that a particular command has begun.';
  1059. EC_DVD_CMD_END : result:= 'EC_DVD_CMD_END - Signals that a particular command has completed.';
  1060. EC_DVD_CURRENT_HMSF_TIME : result:= 'EC_DVD_CURRENT_HMSF_TIME - Signals the current time in DVD_HMSF_TIMECODE format at the beginning of every VOBU, which occurs every .4 to 1.0 sec.';
  1061. EC_DVD_CURRENT_TIME : result:= 'EC_DVD_CURRENT_TIME - Signals the beginning of every video object unit (VOBU), a video segment which is 0.4 to 1.0 seconds in length.';
  1062. EC_DVD_DISC_EJECTED : result:= 'EC_DVD_DISC_EJECTED - Signals that a disc has been ejected from the drive.';
  1063. EC_DVD_DISC_INSERTED : result:= 'EC_DVD_DISC_INSERTED - Signals that a disc has been inserted into the drive.';
  1064. EC_DVD_DOMAIN_CHANGE : result:= 'EC_DVD_DOMAIN_CHANGE - Indicates the DVD Navigator''s new domain.';
  1065. EC_DVD_ERROR : result:= 'EC_DVD_ERROR - Signals a DVD error condition.';
  1066. EC_DVD_KARAOKE_MODE : result:= 'EC_DVD_KARAOKE_MODE - Indicates that the Navigator has either begun playing or finished playing karaoke data.';
  1067. EC_DVD_NO_FP_PGC : result:= 'EC_DVD_NO_FP_PGC - Indicates that the DVD disc does not have a FP_PGC (First Play Program Chain).';
  1068. EC_DVD_PARENTAL_LEVEL_CHANGE : result:= 'EC_DVD_PARENTAL_LEVEL_CHANGE - Signals that the parental level of the authored content is about to change.';
  1069. EC_DVD_PLAYBACK_RATE_CHANGE : result:= 'EC_DVD_PLAYBACK_RATE_CHANGE - Indicates that a playback rate change has been initiated and the new rate is in the parameter.';
  1070. EC_DVD_PLAYBACK_STOPPED : result:= 'EC_DVD_PLAYBACK_STOPPED - Indicates that playback has been stopped. The DVD Navigator has completed playback of the title and did not find any other branching instruction for subsequent playback.';
  1071. EC_DVD_PLAYPERIOD_AUTOSTOP : result:= 'EC_DVD_PLAYPERIOD_AUTOSTOP - Indicates that the Navigator has finished playing the segment specified in a call to PlayPeriodInTitleAutoStop.';
  1072. EC_DVD_STILL_OFF : result:= 'EC_DVD_STILL_OFF - Signals the end of any still.';
  1073. EC_DVD_STILL_ON : result:= 'EC_DVD_STILL_ON - Signals the beginning of any still.';
  1074. EC_DVD_SUBPICTURE_STREAM_CHANGE : result:= 'EC_DVD_SUBPICTURE_STREAM_CHANGE - Signals that the current subpicture stream number changed for the main title.';
  1075. EC_DVD_TITLE_CHANGE : result:= 'EC_DVD_TITLE_CHANGE - Indicates when the current title number changes.';
  1076. EC_DVD_VALID_UOPS_CHANGE : result:= 'EC_DVD_VALID_UOPS_CHANGE - Signals that the available set of IDVDControl2 interface methods has changed.';
  1077. EC_DVD_WARNING : result:= 'EC_DVD_WARNING - Signals a DVD warning condition.'
  1078. else
  1079. result := format('Unknow Graph Event ($%x)',[code]);
  1080. end;
  1081. end;
  1082. // general purpose function to delete a heap allocated AM_MEDIA_TYPE structure
  1083. // which is useful when calling IEnumMediaTypes::Next as the interface
  1084. // implementation allocates the structures which you must later delete
  1085. // the format block may also be a pointer to an interface to release
  1086. procedure DeleteMediaType(pmt: PAMMediaType);
  1087. begin
  1088. // allow nil pointers for coding simplicity
  1089. if (pmt = nil) then exit;
  1090. FreeMediaType(pmt);
  1091. CoTaskMemFree(pmt);
  1092. end;
  1093. // this also comes in useful when using the IEnumMediaTypes interface so
  1094. // that you can copy a media type, you can do nearly the same by creating
  1095. // a CMediaType object but as soon as it goes out of scope the destructor
  1096. // will delete the memory it allocated (this takes a copy of the memory)
  1097. function CreateMediaType(pSrc: PAMMediaType): PAMMediaType;
  1098. var pMediaType: PAMMediaType;
  1099. begin
  1100. ASSERT(pSrc<>nil);
  1101. // Allocate a block of memory for the media type
  1102. pMediaType := CoTaskMemAlloc(sizeof(TAMMediaType));
  1103. if (pMediaType = nil) then
  1104. begin
  1105. result := nil;
  1106. exit;
  1107. end;
  1108. // Copy the variable length format block
  1109. CopyMediaType(pMediaType,pSrc);
  1110. result := pMediaType;
  1111. end;
  1112. //----------------------------------------------------------------------------
  1113. // Copies a task-allocated AM_MEDIA_TYPE structure.
  1114. //----------------------------------------------------------------------------
  1115. procedure CopyMediaType(pmtTarget: PAMMediaType; pmtSource: PAMMediaType);
  1116. begin
  1117. // We'll leak if we copy onto one that already exists - there's one
  1118. // case we can check like that - copying to itself.
  1119. ASSERT(pmtSource <> pmtTarget);
  1120. //pmtTarget^ := pmtSource^;
  1121. move(pmtSource^, pmtTarget^, SizeOf(TAMMediaType));
  1122. if (pmtSource.cbFormat <> 0) then
  1123. begin
  1124. ASSERT(pmtSource.pbFormat <> nil);
  1125. pmtTarget.pbFormat := CoTaskMemAlloc(pmtSource.cbFormat);
  1126. if (pmtTarget.pbFormat = nil) then
  1127. pmtTarget.cbFormat := 0
  1128. else
  1129. CopyMemory(pmtTarget.pbFormat, pmtSource.pbFormat, pmtTarget.cbFormat);
  1130. end;
  1131. if (pmtTarget.pUnk <> nil) then pmtTarget.pUnk._AddRef;
  1132. end;
  1133. procedure FreeMediaType(mt: PAMMediaType);
  1134. begin
  1135. if (mt^.cbFormat <> 0) then
  1136. begin
  1137. CoTaskMemFree(mt^.pbFormat);
  1138. // Strictly unnecessary but tidier
  1139. mt^.cbFormat := 0;
  1140. mt^.pbFormat := nil;
  1141. end;
  1142. if (mt^.pUnk <> nil) then mt^.pUnk := nil;
  1143. end;
  1144. //----------------------------------------------------------------------------
  1145. // Initializes a media type structure given a wave format structure.
  1146. //----------------------------------------------------------------------------
  1147. function CreateAudioMediaType(pwfx: PWaveFormatEx; pmt: PAMMediaType; bSetFormat: boolean): HRESULT;
  1148. begin
  1149. pmt.majortype := MEDIATYPE_Audio;
  1150. if (pwfx.wFormatTag = WAVE_FORMAT_EXTENSIBLE) then
  1151. pmt.subtype := PWAVEFORMATEXTENSIBLE(pwfx).SubFormat
  1152. else
  1153. pmt.subtype := FOURCCMap(pwfx.wFormatTag);
  1154. pmt.formattype := FORMAT_WaveFormatEx;
  1155. pmt.bFixedSizeSamples := TRUE;
  1156. pmt.bTemporalCompression := FALSE;
  1157. pmt.lSampleSize := pwfx.nBlockAlign;
  1158. pmt.pUnk := nil;
  1159. if (bSetFormat) then
  1160. begin
  1161. if (pwfx.wFormatTag = WAVE_FORMAT_PCM) then
  1162. pmt.cbFormat := sizeof(TWAVEFORMATEX)
  1163. else
  1164. pmt.cbFormat := sizeof(TWAVEFORMATEX) + pwfx.cbSize;
  1165. pmt.pbFormat := CoTaskMemAlloc(pmt.cbFormat);
  1166. if (pmt.pbFormat = nil) then
  1167. begin
  1168. result := E_OUTOFMEMORY;
  1169. exit;
  1170. end;
  1171. if (pwfx.wFormatTag = WAVE_FORMAT_PCM) then
  1172. begin
  1173. CopyMemory(pmt.pbFormat, pwfx, sizeof(PCMWAVEFORMAT));
  1174. PWAVEFORMATEX(pmt.pbFormat).cbSize := 0;
  1175. end
  1176. else
  1177. begin
  1178. CopyMemory(pmt.pbFormat, pwfx, pmt.cbFormat);
  1179. end;
  1180. end;
  1181. result := S_OK;
  1182. end;
  1183. function FOURCCMap(Fourcc: Cardinal): TGUID;
  1184. const tmpguid : TGUID = '{00000000-0000-0010-8000-00AA00389B71}';
  1185. begin
  1186. result := tmpguid;
  1187. result.D1 := Fourcc;
  1188. end;
  1189. { Convert a FCC (Four Char Codes) to Cardinal. A FCC identifie a media type.}
  1190. {$NODEFINE FCC}
  1191. function FCC(str: String): Cardinal;
  1192. begin
  1193. Assert(Length(str) >= 4);
  1194. result := PDWORD(str)^;
  1195. end;
  1196. function GetFOURCC(Fourcc: Cardinal): string;
  1197. type TFOURCC= array[0..3] of char;
  1198. var CC: TFOURCC;
  1199. begin
  1200. case Fourcc of
  1201. 0 : result := 'RGB';
  1202. 1 : result := 'RLE8';
  1203. 2 : result := 'RLE4';
  1204. 3 : result := 'BITFIELDS';
  1205. else
  1206. PDWORD(@CC)^ := Fourcc; // abracadabra
  1207. result := CC;
  1208. end;
  1209. end;
  1210. {$NODEFINE MAKEFOURCC}
  1211. function MAKEFOURCC(ch0, ch1, ch2, ch3: char): Cardinal;
  1212. begin
  1213. result := Cardinal(BYTE(ch0)) or
  1214. (Cardinal(BYTE(ch1)) shl 8) or
  1215. (Cardinal(BYTE(ch2)) shl 16) or
  1216. (Cardinal(BYTE(ch3)) shl 24)
  1217. end;
  1218. function GetErrorString(hr: HRESULT): string;
  1219. var buffer: array[0..254] of char;
  1220. begin
  1221. AMGetErrorText(hr,@buffer,255);
  1222. result := buffer;
  1223. end;
  1224. function GetMediaTypeDescription(MediaType: PAMMediaType): string;
  1225. begin
  1226. // major types
  1227. result := 'Major Type: ';
  1228. if IsEqualGUID(MediaType.majortype,MEDIATYPE_AnalogAudio) then result := result+'AnalogAudio' else
  1229. if IsEqualGUID(MediaType.majortype,MEDIATYPE_AnalogVideo) then result := result+'Analogvideo' else
  1230. if IsEqualGUID(MediaType.majortype,MEDIATYPE_Audio) then result := result+'Audio' else
  1231. if IsEqualGUID(MediaType.majortype,MEDIATYPE_AUXLine21Data) then result := result+'AUXLine21Data' else
  1232. if IsEqualGUID(MediaType.majortype,MEDIATYPE_File) then result := result+'File' else
  1233. if IsEqualGUID(MediaType.majortype,MEDIATYPE_Interleaved) then result := result+'Interleaved' else
  1234. if IsEqualGUID(MediaType.majortype,MEDIATYPE_LMRT) then result := result+'LMRT' else
  1235. if IsEqualGUID(MediaType.majortype,MEDIATYPE_Midi) then result := result+'Midi' else
  1236. if IsEqualGUID(MediaType.majortype,MEDIATYPE_MPEG2_PES) then result := result+'MPEG2_PES' else
  1237. if IsEqualGUID(MediaType.majortype,MEDIATYPE_ScriptCommand) then result := result+'ScriptCommand' else
  1238. if IsEqualGUID(MediaType.majortype,MEDIATYPE_Stream) then result := result+'Stream' else
  1239. if IsEqualGUID(MediaType.majortype,MEDIATYPE_Text) then result := result+'Text' else
  1240. if IsEqualGUID(MediaType.majortype,MEDIATYPE_Timecode) then result := result+'Timecode' else
  1241. if IsEqualGUID(MediaType.majortype,MEDIATYPE_URL_STREAM) then result := result+'URL_STREAM' else
  1242. if IsEqualGUID(MediaType.majortype,MEDIATYPE_Video) then result := result+'Video' else
  1243. result := result+'UnKnown ';
  1244. // sub types
  1245. result := result + ' - Sub Type: ';
  1246. if IsEqualGUID(MediaType.subtype,MEDIASUBTYPE_CLPL) then result := result+'CLPL' else
  1247. if IsEqualGUID(MediaType.subtype,MEDIASUBTYPE_YUYV) then result := result+'YUYV' else
  1248. if IsEqualGUID(MediaType.subtype,MEDIASUBTYPE_IYUV) then result := result+'IYUV' else
  1249. if IsEqualGUID(MediaType.subtype,MEDIASUBTYPE_YVU9) then result := result+'YVU9' else
  1250. if IsEqualGUID(MediaType.subtype,MEDIASUBTYPE_Y411) then result := result+'Y411' else
  1251. if IsEqualGUID(MediaType.subtype,MEDIASUBTYPE_Y41P) then result := result+'Y41P' else
  1252. if IsEqualGUID(MediaType.subtype,MEDIASUBTYPE_YUY2) then result := result+'YUY2' else
  1253. if IsEqualGUID(MediaType.subtype,MEDIASUBTYPE_YVYU) then result := result+'YVYU' else
  1254. if IsEqualGUID(MediaType.subtype,MEDIASUBTYPE_UYVY) then result := result+'UYVY' else
  1255. if IsEqualGUID(MediaType.subtype,MEDIASUBTYPE_Y211) then result := result+'Y211' else
  1256. if IsEqualGUID(MediaType.subtype,MEDIASUBTYPE_YV12) then result := result+'YV12' else
  1257. if IsEqualGUID(MediaType.subtype,MEDIASUBTYPE_CLJR) then result := result+'CLJR' else
  1258. if IsEqualGUID(MediaType.subtype,MEDIASUBTYPE_IF09) then result := result+'IF09' else
  1259. if IsEqualGUID(MediaType.subtype,MEDIASUBTYPE_CPLA) then result := result+'CPLA' else
  1260. if IsEqualGUID(MediaType.subtype,MEDIASUBTYPE_MJPG) then result := result+'MJPG' else
  1261. if IsEqualGUID(MediaType.subtype,MEDIASUBTYPE_TVMJ) then result := result+'TVMJ' else
  1262. if IsEqualGUID(MediaType.subtype,MEDIASUBTYPE_WAKE) then result := result+'WAKE' else
  1263. if IsEqualGUID(MediaType.subtype,MEDIASUBTYPE_CFCC) then result := result+'CFCC' else
  1264. if IsEqualGUID(MediaType.subtype,MEDIASUBTYPE_IJPG) then result := result+'IJPG' else
  1265. if IsEqualGUID(MediaType.subtype,MEDIASUBTYPE_Plum) then result := result+'Plum' else
  1266. if IsEqualGUID(MediaType.subtype,MEDIASUBTYPE_DVCS) then result := result+'DVCS' else
  1267. if IsEqualGUID(MediaType.subtype,MEDIASUBTYPE_DVSD) then result := result+'DVSD' else
  1268. if IsEqualGUID(MediaType.subtype,MEDIASUBTYPE_MDVF) then result := result+'MDVF' else
  1269. if IsEqualGUID(MediaType.subtype,MEDIASUBTYPE_RGB1) then result := result+'RGB1' else
  1270. if IsEqualGUID(MediaType.subtype,MEDIASUBTYPE_RGB4) then result := result+'RGB4' else
  1271. if IsEqualGUID(MediaType.subtype,MEDIASUBTYPE_RGB8) then result := result+'RGB8' else
  1272. if IsEqualGUID(MediaType.subtype,MEDIASUBTYPE_RGB565) then result := result+'RGB565' else
  1273. if IsEqualGUID(MediaType.subtype,MEDIASUBTYPE_RGB555) then result := result+'RGB555' else
  1274. if IsEqualGUID(MediaType.subtype,MEDIASUBTYPE_RGB24) then result := result+'RGB24' else
  1275. if IsEqualGUID(MediaType.subtype,MEDIASUBTYPE_RGB32) then result := result+'RGB32' else
  1276. if IsEqualGUID(MediaType.subtype,MEDIASUBTYPE_ARGB32) then result := result+'ARGB32' else
  1277. if IsEqualGUID(MediaType.subtype,MEDIASUBTYPE_Overlay) then result := result+'Overlay' else
  1278. if IsEqualGUID(MediaType.subtype,MEDIASUBTYPE_MPEG1Packet) then result := result+'MPEG1Packet' else
  1279. if IsEqualGUID(MediaType.subtype,MEDIASUBTYPE_MPEG1Payload) then result := result+'MPEG1Payload' else
  1280. if IsEqualGUID(MediaType.subtype,MEDIASUBTYPE_MPEG1AudioPayload) then result := result+'MPEG1AudioPayload' else
  1281. if IsEqualGUID(MediaType.subtype,MEDIASUBTYPE_MPEG1System) then result := result+'MPEG1System' else
  1282. if IsEqualGUID(MediaType.subtype,MEDIASUBTYPE_MPEG1VideoCD) then result := result+'MPEG1VideoCD' else
  1283. if IsEqualGUID(MediaType.subtype,MEDIASUBTYPE_MPEG1Video) then result := result+'MPEG1Video' else
  1284. if IsEqualGUID(MediaType.subtype,MEDIASUBTYPE_MPEG1Audio) then result := result+'MPEG1Audio' else
  1285. if IsEqualGUID(MediaType.subtype,MEDIASUBTYPE_Avi) then result := result+'Avi' else
  1286. if IsEqualGUID(MediaType.subtype,MEDIASUBTYPE_Asf) then result := result+'Asf' else
  1287. if IsEqualGUID(MediaType.subtype,MEDIASUBTYPE_QTMovie) then result := result+'QTMovie' else
  1288. if IsEqualGUID(MediaType.subtype,MEDIASUBTYPE_QTRpza) then result := result+'QTRpza' else
  1289. if IsEqualGUID(MediaType.subtype,MEDIASUBTYPE_QTSmc) then result := result+'QTSmc' else
  1290. if IsEqualGUID(MediaType.subtype,MEDIASUBTYPE_QTRle) then result := result+'QTRle' else
  1291. if IsEqualGUID(MediaType.subtype,MEDIASUBTYPE_QTJpeg) then result := result+'QTJpeg' else
  1292. if IsEqualGUID(MediaType.subtype,MEDIASUBTYPE_PCMAudio_Obsolete) then result := result+'PCMAudio_Obsolete' else
  1293. if IsEqualGUID(MediaType.subtype,MEDIASUBTYPE_PCM) then result := result+'PCM' else
  1294. if IsEqualGUID(MediaType.subtype,MEDIASUBTYPE_WAVE) then result := result+'WAVE' else
  1295. if IsEqualGUID(MediaType.subtype,MEDIASUBTYPE_AU) then result := result+'AU' else
  1296. if IsEqualGUID(MediaType.subtype,MEDIASUBTYPE_AIFF) then result := result+'AIFF' else
  1297. if IsEqualGUID(MediaType.subtype,MEDIASUBTYPE_dvsd_) then result := result+'dvsd_' else
  1298. if IsEqualGUID(MediaType.subtype,MEDIASUBTYPE_dvhd) then result := result+'dvhd' else
  1299. if IsEqualGUID(MediaType.subtype,MEDIASUBTYPE_dvsl) then result := result+'dvsl' else
  1300. if IsEqualGUID(MediaType.subtype,MEDIASUBTYPE_Line21_BytePair) then result := result+'Line21_BytePair' else
  1301. if IsEqualGUID(MediaType.subtype,MEDIASUBTYPE_Line21_GOPPacket) then result := result+'Line21_GOPPacket' else
  1302. if IsEqualGUID(MediaType.subtype,MEDIASUBTYPE_Line21_VBIRawData) then result := result+'Line21_VBIRawData' else
  1303. if IsEqualGUID(MediaType.subtype,MEDIASUBTYPE_DRM_Audio) then result := result+'DRM_Audio' else
  1304. if IsEqualGUID(MediaType.subtype,MEDIASUBTYPE_IEEE_FLOAT) then result := result+'IEEE_FLOAT' else
  1305. if IsEqualGUID(MediaType.subtype,MEDIASUBTYPE_DOLBY_AC3_SPDIF) then result := result+'DOLBY_AC3_SPDIF' else
  1306. if IsEqualGUID(MediaType.subtype,MEDIASUBTYPE_RAW_SPORT) then result := result+'RAW_SPORT' else
  1307. if IsEqualGUID(MediaType.subtype,MEDIASUBTYPE_SPDIF_TAG_241h) then result := result+'SPDIF_TAG_241h' else
  1308. if IsEqualGUID(MediaType.subtype,MEDIASUBTYPE_DssVideo) then result := result+'DssVideo' else
  1309. if IsEqualGUID(MediaType.subtype,MEDIASUBTYPE_DssAudio) then result := result+'DssAudio' else
  1310. if IsEqualGUID(MediaType.subtype,MEDIASUBTYPE_VPVideo) then result := result+'VPVideo' else
  1311. if IsEqualGUID(MediaType.subtype,MEDIASUBTYPE_VPVBI) then result := result+'VPVBI' else
  1312. if IsEqualGUID(MediaType.subtype,MEDIASUBTYPE_AnalogVideo_NTSC_M) then result := result+'AnalogVideo_NTSC_M' else
  1313. if IsEqualGUID(MediaType.subtype,MEDIASUBTYPE_AnalogVideo_PAL_B) then result := result+'AnalogVideo_PAL_B' else
  1314. if IsEqualGUID(MediaType.subtype,MEDIASUBTYPE_AnalogVideo_PAL_D) then result := result+'AnalogVideo_PAL_D' else
  1315. if IsEqualGUID(MediaType.subtype,MEDIASUBTYPE_AnalogVideo_PAL_G) then result := result+'AnalogVideo_PAL_G' else
  1316. if IsEqualGUID(MediaType.subtype,MEDIASUBTYPE_AnalogVideo_PAL_H) then result := result+'AnalogVideo_PAL_H' else
  1317. if IsEqualGUID(MediaType.subtype,MEDIASUBTYPE_AnalogVideo_PAL_I) then result := result+'AnalogVideo_PAL_I' else
  1318. if IsEqualGUID(MediaType.subtype,MEDIASUBTYPE_AnalogVideo_PAL_M) then result := result+'AnalogVideo_PAL_M' else
  1319. if IsEqualGUID(MediaType.subtype,MEDIASUBTYPE_AnalogVideo_PAL_N) then result := result+'AnalogVideo_PAL_N' else
  1320. if IsEqualGUID(MediaType.subtype,MEDIASUBTYPE_AnalogVideo_PAL_N_COMBO) then result := result+'AnalogVideo_PAL_N_COMBO' else
  1321. if IsEqualGUID(MediaType.subtype,MEDIASUBTYPE_AnalogVideo_SECAM_B) then result := result+'AnalogVideo_SECAM_B' else
  1322. if IsEqualGUID(MediaType.subtype,MEDIASUBTYPE_AnalogVideo_SECAM_D) then result := result+'AnalogVideo_SECAM_D' else
  1323. if IsEqualGUID(MediaType.subtype,MEDIASUBTYPE_AnalogVideo_SECAM_G) then result := result+'AnalogVideo_SECAM_G' else
  1324. if IsEqualGUID(MediaType.subtype,MEDIASUBTYPE_AnalogVideo_SECAM_H) then result := result+'AnalogVideo_SECAM_H' else
  1325. if IsEqualGUID(MediaType.subtype,MEDIASUBTYPE_AnalogVideo_SECAM_K) then result := result+'AnalogVideo_SECAM_K' else
  1326. if IsEqualGUID(MediaType.subtype,MEDIASUBTYPE_AnalogVideo_SECAM_K1) then result := result+'AnalogVideo_SECAM_K1' else
  1327. if IsEqualGUID(MediaType.subtype,MEDIASUBTYPE_AnalogVideo_SECAM_L) then result := result+'AnalogVideo_SECAM_L' else
  1328. if IsEqualGUID(MediaType.subtype,MEDIASUBTYPE_MPEG2_VIDEO) then result := result+'MPEG2_VIDEO' else
  1329. if IsEqualGUID(MediaType.subtype,MEDIASUBTYPE_MPEG2_PROGRAM) then result := result+'MPEG2_PROGRAM' else
  1330. if IsEqualGUID(MediaType.subtype,MEDIASUBTYPE_MPEG2_TRANSPORT) then result := result+'MPEG2_TRANSPORT' else
  1331. if IsEqualGUID(MediaType.subtype,MEDIASUBTYPE_MPEG2_AUDIO) then result := result+'MPEG2_AUDIO' else
  1332. if IsEqualGUID(MediaType.subtype,MEDIASUBTYPE_DOLBY_AC3) then result := result+'DOLBY_AC3' else
  1333. if IsEqualGUID(MediaType.subtype,MEDIASUBTYPE_DVD_SUBPICTURE) then result := result+'DVD_SUBPICTURE' else
  1334. if IsEqualGUID(MediaType.subtype,MEDIASUBTYPE_DVD_LPCM_AUDIO) then result := result+'DVD_LPCM_AUDIO' else
  1335. if IsEqualGUID(MediaType.subtype,MEDIASUBTYPE_DTS) then result := result+'DTS' else
  1336. if IsEqualGUID(MediaType.subtype,MEDIASUBTYPE_SDDS) then result := result+'SDDS' else
  1337. if IsEqualGUID(MediaType.subtype,MEDIASUBTYPE_DVD_NAVIGATION_PCI) then result := result+'PCI' else
  1338. if IsEqualGUID(MediaType.subtype,MEDIASUBTYPE_DVD_NAVIGATION_DSI) then result := result+'DSI' else
  1339. if IsEqualGUID(MediaType.subtype,MEDIASUBTYPE_DVD_NAVIGATION_PROVIDER) then result := result+'PROVIDER' else
  1340. if IsEqualGUID(MediaType.subtype,MEDIASUBTYPE_MP42) then result := result+'MS-MPEG4' else
  1341. if IsEqualGUID(MediaType.subtype,MEDIASUBTYPE_DIVX) then result := result+'DIVX' else
  1342. if IsEqualGUID(MediaType.subtype,MEDIASUBTYPE_VOXWARE) then result := result+'VOXWARE_MetaSound' else
  1343. result := result+'UnKnown ';
  1344. // format
  1345. result := result+ ' Format: ';
  1346. if IsEqualGUID(MediaType.formattype,FORMAT_VideoInfo) then
  1347. begin
  1348. result := result+'VideoInfo ';
  1349. if ((MediaType.cbFormat > 0) and assigned(MediaType.pbFormat)) then
  1350. with PVideoInfoHeader(MediaType.pbFormat)^.bmiHeader do
  1351. result := result + format('%s %dX%d, %d bits',
  1352. [GetFOURCC(biCompression), biWidth, biHeight, biBitCount]);
  1353. end
  1354. else
  1355. begin
  1356. if IsEqualGUID(MediaType.formattype,FORMAT_VideoInfo2) then
  1357. begin
  1358. result := result+'VideoInfo2 ';
  1359. if ((MediaType.cbFormat > 0) and assigned(MediaType.pbFormat)) then
  1360. with PVideoInfoHeader2(MediaType.pbFormat)^.bmiHeader do
  1361. result := result + format('%s %dX%d, %d bits',
  1362. [GetFOURCC(biCompression), biWidth, biHeight, biBitCount]);
  1363. end
  1364. else
  1365. begin
  1366. if IsEqualGUID(MediaType.formattype,FORMAT_WaveFormatEx) then
  1367. begin
  1368. result := result+'WaveFormatEx: ';
  1369. if ((MediaType.cbFormat > 0) and assigned(MediaType.pbFormat)) then
  1370. begin
  1371. case PWaveFormatEx(MediaType.pbFormat)^.wFormatTag of
  1372. $0001: result := result+'PCM'; // common
  1373. $0002: result := result+'ADPCM';
  1374. $0003: result := result+'IEEE_FLOAT';
  1375. $0005: result := result+'IBM_CVSD';
  1376. $0006: result := result+'ALAW';
  1377. $0007: result := result+'MULAW';
  1378. $0010: result := result+'OKI_ADPCM';
  1379. $0011: result := result+'DVI_ADPCM';
  1380. $0012: result := result+'MEDIASPACE_ADPCM';
  1381. $0013: result := result+'SIERRA_ADPCM';
  1382. $0014: result := result+'G723_ADPCM';
  1383. $0015: result := result+'DIGISTD';
  1384. $0016: result := result+'DIGIFIX';
  1385. $0017: result := result+'DIALOGIC_OKI_ADPCM';
  1386. $0018: result := result+'MEDIAVISION_ADPCM';
  1387. $0020: result := result+'YAMAHA_ADPCM';
  1388. $0021: result := result+'SONARC';
  1389. $0022: result := result+'DSPGROUP_TRUESPEECH';
  1390. $0023: result := result+'ECHOSC1';
  1391. $0024: result := result+'AUDIOFILE_AF36';
  1392. $0025: result := result+'APTX';
  1393. $0026: result := result+'AUDIOFILE_AF10';
  1394. $0030: result := result+'DOLBY_AC2';
  1395. $0031: result := result+'GSM610';
  1396. $0032: result := result+'MSNAUDIO';
  1397. $0033: result := result+'ANTEX_ADPCME';
  1398. $0034: result := result+'CONTROL_RES_VQLPC';
  1399. $0035: result := result+'DIGIREAL';
  1400. $0036: result := result+'DIGIADPCM';
  1401. $0037: result := result+'CONTROL_RES_CR10';
  1402. $0038: result := result+'NMS_VBXADPCM';
  1403. $0039: result := result+'CS_IMAADPCM';
  1404. $003A: result := result+'ECHOSC3';
  1405. $003B: result := result+'ROCKWELL_ADPCM';
  1406. $003C: result := result+'ROCKWELL_DIGITALK';
  1407. $003D: result := result+'XEBEC';
  1408. $0040: result := result+'G721_ADPCM';
  1409. $0041: result := result+'G728_CELP';
  1410. $0050: result := result+'MPEG';
  1411. $0055: result := result+'MPEGLAYER3';
  1412. $0060: result := result+'CIRRUS';
  1413. $0061: result := result+'ESPCM';
  1414. $0062: result := result+'VOXWARE';
  1415. $0063: result := result+'CANOPUS_ATRAC';
  1416. $0064: result := result+'G726_ADPCM';
  1417. $0065: result := result+'G722_ADPCM';
  1418. $0066: result := result+'DSAT';
  1419. $0067: result := result+'DSAT_DISPLAY';
  1420. $0075: result := result+'VOXWARE'; // aditionnal ???
  1421. $0080: result := result+'SOFTSOUND';
  1422. $0100: result := result+'RHETOREX_ADPCM';
  1423. $0200: result := result+'CREATIVE_ADPCM';
  1424. $0202: result := result+'CREATIVE_FASTSPEECH8';
  1425. $0203: result := result+'CREATIVE_FASTSPEECH10';
  1426. $0220: result := result+'QUARTERDECK';
  1427. $0300: result := result+'FM_TOWNS_SND';
  1428. $0400: result := result+'BTV_DIGITAL';
  1429. $1000: result := result+'OLIGSM';
  1430. $1001: result := result+'OLIADPCM';
  1431. $1002: result := result+'OLICELP';
  1432. $1003: result := result+'OLISBC';
  1433. $1004: result := result+'OLIOPR';
  1434. $1100: result := result+'LH_CODEC';
  1435. $1400: result := result+'NORRIS';
  1436. else
  1437. result := result+'Unknown';
  1438. end;
  1439. with PWaveFormatEx(MediaType.pbFormat)^ do
  1440. result := result + format(', %d Hertz, %d Bits, %d Channels',
  1441. [nSamplesPerSec, wBitsPerSample, nChannels]);
  1442. end;
  1443. end
  1444. else
  1445. begin
  1446. if IsEqualGUID(MediaType.formattype,FORMAT_MPEGVideo) then
  1447. begin
  1448. result := result+'MPEGVideo ';
  1449. if ((MediaType.cbFormat > 0) and assigned(MediaType.pbFormat)) then
  1450. with PMPEG1VIDEOINFO(MediaType.pbFormat)^.hdr.bmiHeader do
  1451. result := result + format('%s %dX%d, %d bits',
  1452. [GetFOURCC(biCompression), biWidth, biHeight, biBitCount]);
  1453. end
  1454. else
  1455. begin
  1456. if IsEqualGUID(MediaType.formattype,FORMAT_MPEG2Video) then
  1457. begin
  1458. result := result+'MPEGStreams ';
  1459. if ((MediaType.cbFormat > 0) and assigned(MediaType.pbFormat)) then
  1460. with PMPEG2VIDEOINFO(MediaType.pbFormat)^.hdr.bmiHeader do
  1461. result := result + format('%s %dX%d, %d bits',
  1462. [GetFOURCC(biCompression), biWidth, biHeight, biBitCount]);
  1463. end
  1464. else
  1465. begin // todo
  1466. if IsEqualGUID(MediaType.formattype,FORMAT_DvInfo) then result := result+'DvInfo' else
  1467. if IsEqualGUID(MediaType.formattype,FORMAT_MPEGStreams) then result := result+'MPEGStreams' else
  1468. if IsEqualGUID(MediaType.formattype,FORMAT_DolbyAC3) then result := result+'DolbyAC3' else
  1469. if IsEqualGUID(MediaType.formattype,FORMAT_MPEG2Audio) then result := result+'MPEG2Audio' else
  1470. if IsEqualGUID(MediaType.formattype,FORMAT_DVD_LPCMAudio) then result := result+'DVD_LPCMAudio' else
  1471. result := result+'Unknown';
  1472. end;
  1473. end;
  1474. end;
  1475. end;
  1476. end;
  1477. end;
  1478. function ShowFilterPropertyPage(parent: THandle; Filter: IBaseFilter;
  1479. PropertyPage: TPropertyPage = ppDefault): HRESULT;
  1480. var
  1481. SpecifyPropertyPages : ISpecifyPropertyPages;
  1482. CaptureDialog : IAMVfwCaptureDialogs;
  1483. CompressDialog: IAMVfwCompressDialogs;
  1484. CAGUID :TCAGUID;
  1485. FilterInfo: TFilterInfo;
  1486. Code: Integer;
  1487. begin
  1488. result := S_FALSE;
  1489. code := 0;
  1490. if Filter = nil then exit;
  1491. ZeroMemory(@FilterInfo, SizeOf(TFilterInfo));
  1492. case PropertyPage of
  1493. ppVFWCapDisplay: code := VfwCaptureDialog_Display;
  1494. ppVFWCapFormat : code := VfwCaptureDialog_Format;
  1495. ppVFWCapSource : code := VfwCaptureDialog_Source;
  1496. ppVFWCompConfig: code := VfwCompressDialog_Config;
  1497. ppVFWCompAbout : code := VfwCompressDialog_About;
  1498. end;
  1499. case PropertyPage of
  1500. ppDefault:
  1501. begin
  1502. result := Filter.QueryInterface(IID_ISpecifyPropertyPages, SpecifyPropertyPages);
  1503. if result <> S_OK then exit;
  1504. result := SpecifyPropertyPages.GetPages(CAGUID);
  1505. if result <> S_OK then exit;
  1506. result := Filter.QueryFilterInfo(FilterInfo);
  1507. if result = S_OK then
  1508. begin
  1509. result := OleCreatePropertyFrame(parent, 0, 0, FilterInfo.achName, 1, @Filter, CAGUID.cElems, CAGUID.pElems, 0, 0, nil );
  1510. FilterInfo.pGraph := nil;
  1511. end;
  1512. if Assigned(CAGUID.pElems) then CoTaskMemFree(CAGUID.pElems);
  1513. SpecifyPropertyPages := nil;
  1514. end;
  1515. ppVFWCapDisplay..ppVFWCapSource:
  1516. begin
  1517. result := Filter.QueryInterface(IID_IAMVfwCaptureDialogs,CaptureDialog);
  1518. if (result <> S_OK) then exit;
  1519. result := CaptureDialog.HasDialog(code);
  1520. if result <> S_OK then exit;
  1521. result := CaptureDialog.ShowDialog(code,parent);
  1522. CaptureDialog := nil;
  1523. end;
  1524. ppVFWCompConfig..ppVFWCompAbout:
  1525. begin
  1526. result := Filter.QueryInterface(IID_IAMVfwCompressDialogs, CompressDialog);
  1527. if (result <> S_OK) then exit;
  1528. case PropertyPage of
  1529. ppVFWCompConfig: result := CompressDialog.ShowDialog(VfwCompressDialog_QueryConfig, 0);
  1530. ppVFWCompAbout : result := CompressDialog.ShowDialog(VfwCompressDialog_QueryAbout, 0);
  1531. end;
  1532. if result = S_OK then result := CompressDialog.ShowDialog(code,parent);
  1533. CompressDialog := nil;
  1534. end;
  1535. end;
  1536. end;
  1537. function HaveFilterPropertyPage(Filter: IBaseFilter;
  1538. PropertyPage: TPropertyPage = ppDefault): boolean;
  1539. var
  1540. SpecifyPropertyPages : ISpecifyPropertyPages;
  1541. CaptureDialog : IAMVfwCaptureDialogs;
  1542. CompressDialog: IAMVfwCompressDialogs;
  1543. Code: Integer;
  1544. HR: HRESULT;
  1545. begin
  1546. result := false;
  1547. code := 0;
  1548. if Filter = nil then exit;
  1549. case PropertyPage of
  1550. ppVFWCapDisplay: code := VfwCaptureDialog_Display;
  1551. ppVFWCapFormat : code := VfwCaptureDialog_Format;
  1552. ppVFWCapSource : code := VfwCaptureDialog_Source;
  1553. ppVFWCompConfig: code := VfwCompressDialog_QueryConfig;
  1554. ppVFWCompAbout : code := VfwCompressDialog_QueryAbout;
  1555. end;
  1556. case PropertyPage of
  1557. ppDefault:
  1558. begin
  1559. result := Succeeded(Filter.QueryInterface(IID_ISpecifyPropertyPages, SpecifyPropertyPages));
  1560. SpecifyPropertyPages := nil;
  1561. end;
  1562. ppVFWCapDisplay..ppVFWCapSource:
  1563. begin
  1564. HR := Filter.QueryInterface(IID_IAMVfwCaptureDialogs,CaptureDialog);
  1565. if (HR <> S_OK) then exit;
  1566. result := Succeeded(CaptureDialog.HasDialog(code));
  1567. CaptureDialog := nil;
  1568. end;
  1569. ppVFWCompConfig..ppVFWCompAbout:
  1570. begin
  1571. HR := Filter.QueryInterface(IID_IAMVfwCompressDialogs, CompressDialog);
  1572. if (HR <> S_OK) then exit;
  1573. result := Succeeded(CompressDialog.ShowDialog(code,0));
  1574. CompressDialog := nil;
  1575. end;
  1576. end;
  1577. end;
  1578. function ShowPinPropertyPage(parent: THandle; Pin: IPin): HRESULT;
  1579. var
  1580. SpecifyPropertyPages: ISpecifyPropertyPages;
  1581. CAGUID :TCAGUID;
  1582. PinInfo: TPinInfo;
  1583. begin
  1584. result := S_FALSE;
  1585. if Pin = nil then exit;
  1586. result := Pin.QueryInterface(IID_ISpecifyPropertyPages, SpecifyPropertyPages);
  1587. if result <> S_OK then exit;
  1588. result := SpecifyPropertyPages.GetPages(CAGUID);
  1589. if result <> S_OK then
  1590. begin
  1591. SpecifyPropertyPages := nil;
  1592. Exit;
  1593. end;
  1594. result := Pin.QueryPinInfo(PinInfo);
  1595. if result <> S_OK then exit;
  1596. try
  1597. result := OleCreatePropertyFrame(parent, 0, 0, PinInfo.achName, 1, @Pin,
  1598. CAGUID.cElems, CAGUID.pElems, 0, 0, nil);
  1599. finally
  1600. CoTaskMemFree(CAGUID.pElems);
  1601. PinInfo.pFilter := nil;
  1602. end;
  1603. SpecifyPropertyPages := nil;
  1604. end;
  1605. function RefTimeToMiliSec(RefTime: int64): Cardinal;
  1606. begin
  1607. result := Cardinal(RefTime div 10000);
  1608. end;
  1609. function MiliSecToRefTime(Milisec: int64): Int64;
  1610. begin
  1611. result := Milisec * 10000;
  1612. end;
  1613. // The mechanism for describing a bitmap format is with the BITMAPINFOHEADER
  1614. // This is really messy to deal with because it invariably has fields that
  1615. // follow it holding bit fields, palettes and the rest. This function gives
  1616. // the number of bytes required to hold a VIDEOINFO that represents it. This
  1617. // count includes the prefix information (like the rcSource rectangle) the
  1618. // BITMAPINFOHEADER field, and any other colour information on the end.
  1619. //
  1620. // WARNING If you want to copy a BITMAPINFOHEADER into a VIDEOINFO always make
  1621. // sure that you use the HEADER macro because the BITMAPINFOHEADER field isn't
  1622. // right at the start of the VIDEOINFO (there are a number of other fields),
  1623. //
  1624. // CopyMemory(HEADER(pVideoInfo),pbmi,sizeof(BITMAPINFOHEADER));
  1625. //
  1626. function GetBitmapFormatSize(const Header: TBitmapInfoHeader): Integer;
  1627. var Size, Entries: Integer;
  1628. begin
  1629. // Everyone has this to start with this
  1630. Size := SIZE_PREHEADER + Header.biSize;
  1631. ASSERT(Header.biSize >= sizeof(TBitmapInfoHeader));
  1632. // Does this format use a palette, if the number of colours actually used
  1633. // is zero then it is set to the maximum that are allowed for that colour
  1634. // depth (an example is 256 for eight bits). Truecolour formats may also
  1635. // pass a palette with them in which case the used count is non zero
  1636. // This would scare me.
  1637. ASSERT((Header.biBitCount <= iPALETTE) or (Header.biClrUsed = 0));
  1638. if ((Header.biBitCount <= iPALETTE) or BOOL(Header.biClrUsed)) then
  1639. begin
  1640. Entries := DWORD(1) shl Header.biBitCount;
  1641. if BOOL(Header.biClrUsed) then Entries := Header.biClrUsed;
  1642. Size := Size + Entries * sizeof(RGBQUAD);
  1643. end;
  1644. // Truecolour formats may have a BI_BITFIELDS specifier for compression
  1645. // type which means that room for three DWORDs should be allocated that
  1646. // specify where in each pixel the RGB colour components may be found
  1647. if (Header.biCompression = BI_BITFIELDS) then Size := Size + SIZE_MASKS;
  1648. result := Size;
  1649. end;
  1650. function GetSourceRectFromMediaType(const MediaType: TAMMediaType): TRect;
  1651. function GetbmiHeader(const MediaType: TAMMediaType): PBitmapInfoHeader;
  1652. begin
  1653. result := nil;
  1654. if MediaType.pbFormat = nil then exit;
  1655. if (IsEqualGUID(MediaType.formattype, FORMAT_VideoInfo) and
  1656. (MediaType.cbFormat >= sizeof(TVIDEOINFOHEADER))) then
  1657. result := @PVIDEOINFOHEADER(MediaType.pbFormat)^.bmiHeader
  1658. else if (IsEqualGUID(MediaType.formattype, FORMAT_VideoInfo2) and
  1659. (MediaType.cbFormat >= sizeof(TVIDEOINFOHEADER2))) then
  1660. result := @PVIDEOINFOHEADER2(MediaType.pbFormat)^.bmiHeader;
  1661. end;
  1662. var bih: PBITMAPINFOHEADER;
  1663. begin
  1664. ZeroMemory(@Result,SizeOf(TRect));
  1665. if MediaType.pbFormat = nil then exit;
  1666. if (IsEqualGUID(MediaType.formattype, FORMAT_VideoInfo) and
  1667. (MediaType.cbFormat >= sizeof(TVIDEOINFOHEADER))) then
  1668. result := PVideoInfoHeader(MediaType.pbFormat)^.rcSource
  1669. else if (IsEqualGUID(MediaType.formattype, FORMAT_VideoInfo2) and
  1670. (MediaType.cbFormat >= sizeof(TVIDEOINFOHEADER2))) then
  1671. result := PVIDEOINFOHEADER2(MediaType.pbFormat)^.rcSource;
  1672. if IsRectEmpty(result) then
  1673. begin
  1674. bih := GetbmiHeader(MediaType);
  1675. if bih <> nil then
  1676. SetRect(result, 0, 0, abs(bih.biWidth), abs(bih.biHeight));
  1677. end;
  1678. end;
  1679. function StretchRect(R, IR: TRect): TRect;
  1680. var
  1681. iW, iH: Integer;
  1682. rW, rH: Integer;
  1683. begin
  1684. iW := IR.Right - IR.Left;
  1685. iH := IR.Bottom - IR.Top;
  1686. rW := R.Right - R.Left;
  1687. rH := R.Bottom - R.Top;
  1688. if (rW / iW) < (rH / iH) then
  1689. begin
  1690. iH := MulDiv(iH, rW, iW);
  1691. iW := MulDiv(iW, rW, iW);
  1692. end
  1693. else
  1694. begin
  1695. iW := MulDiv(iW, rH, iH);
  1696. iH := MulDiv(iH, rH, iH);
  1697. end;
  1698. SetRect(Result, 0, 0, iW, iH);
  1699. OffsetRect(Result, R.Left + (rW - iW) div 2, R.Top + (rH - iH) div 2);
  1700. end;
  1701. function CheckDSError(HR: HRESULT): HRESULT;
  1702. var Excep: EDirectShowException;
  1703. begin
  1704. Result := HR;
  1705. if Failed(HR) then
  1706. begin
  1707. Excep := EDirectShowException.Create(format(GetErrorString(HR)+' ($%x).',[HR]));
  1708. Excep.ErrorCode := HR;
  1709. raise Excep;
  1710. end;
  1711. end;
  1712. //-----------------------------------------------------------------------------
  1713. // Name: DXUtil_GetDXSDKMediaPath()
  1714. // Desc: Returns the DirectX SDK media path
  1715. //-----------------------------------------------------------------------------
  1716. function GetDXSDKMediaPath : String;
  1717. var
  1718. strPath : array[1..MAX_PATH+10] of Char;
  1719. Key : HKey;
  1720. dwType, dwSize : DWord;
  1721. lr : Longint;
  1722. begin
  1723. Key := 0;
  1724. dwType := 0;
  1725. dwSize := MAX_PATH;
  1726. // Initialize to NULL
  1727. strPath[1] := #0;
  1728. // Open the appropriate registry key
  1729. lr := RegOpenKeyEx(HKEY_LOCAL_MACHINE, 'Software\Microsoft\DirectX SDK',
  1730. 0, KEY_READ, Key);
  1731. if(ERROR_SUCCESS <> lr) then
  1732. begin
  1733. Result := '';
  1734. Exit;
  1735. end;
  1736. lr := RegQueryValueEx(Key, 'DX9SDK Samples Path', nil,
  1737. @dwType, @strPath, @dwSize);
  1738. if (ERROR_SUCCESS <> lr) then
  1739. begin
  1740. // Reset size field
  1741. dwSize := MAX_PATH;
  1742. lr := RegQueryValueEx(Key, 'DX81SDK Samples Path', nil,
  1743. @dwType, @strPath, @dwSize);
  1744. if (ERROR_SUCCESS <> lr) then
  1745. begin
  1746. // Reset size field
  1747. dwSize := MAX_PATH;
  1748. lr := RegQueryValueEx(Key, 'DX8SDK Samples Path', nil,
  1749. @dwType, @strPath, @dwSize);
  1750. if (ERROR_SUCCESS <> lr) then
  1751. begin
  1752. RegCloseKey(Key);
  1753. Result := '';
  1754. Exit;
  1755. end;
  1756. end;
  1757. end;
  1758. RegCloseKey(Key);
  1759. Result := PChar(@strPath);
  1760. Result := Result + '\Media\';
  1761. end;
  1762. function CopyScreenToBitmap(Rect : TRect; pData : PByte;
  1763. pHeader : PBitmapInfo) : HBitmap;
  1764. var
  1765. // screen DC and memory DC
  1766. hScrDC, hMemDC : HDC;
  1767. // handles to deice-dependent bitmaps
  1768. hBmp, hOldBmp : HBitmap;
  1769. // coordinates of rectangle to grab
  1770. nX, nY, nX2, nY2,
  1771. // DIB width and height
  1772. nWidth, nHeight,
  1773. // screen resolution
  1774. xScrn, yScrn : Integer;
  1775. begin
  1776. // check for an empty rectangle
  1777. if IsRectEmpty(Rect) then
  1778. begin
  1779. Result := 0;
  1780. Exit;
  1781. end;
  1782. // create a DC for the screen and create
  1783. // a memory DC compatible to screen DC
  1784. hScrDC := CreateDC('DISPLAY', nil, nil, nil);
  1785. hMemDC := CreateCompatibleDC(hScrDC);
  1786. // get points of rectangle to grab
  1787. nX := Rect.Left;
  1788. nY := Rect.Top;
  1789. nX2:= Rect.Right;
  1790. nY2:= Rect.Bottom;
  1791. // get screen resolution
  1792. xScrn := GetDeviceCaps(hScrDC, HORZRES);
  1793. yScrn := GetDeviceCaps(hScrDC, VERTRES);
  1794. //make sure bitmap rectangle is visible
  1795. if (nX < 0) then
  1796. nX := 0;
  1797. if (nY < 0) then
  1798. nY := 0;
  1799. if (nX2 > xScrn) then
  1800. nX2 := xScrn;
  1801. if (nY2 > yScrn) then
  1802. nY2 := yScrn;
  1803. nWidth := nX2 - nX;
  1804. nHeight := nY2 - nY;
  1805. // create a bitmap compatible with the screen DC
  1806. hBmp := CreateCompatibleBitmap(hScrDC, nWidth, nHeight);
  1807. // select new bitmap into memory DC
  1808. hOldBmp := SelectObject(hMemDC, hBmp);
  1809. // bitblt screen DC to memory DC
  1810. BitBlt(hMemDC, 0, 0, nWidth, nHeight, hScrDC, nX, nY, SRCCOPY);
  1811. // select old bitmap back into memory DC and get handle to
  1812. // bitmap of the screen
  1813. hBmp := SelectObject(hMemDC, hOldBmp);
  1814. // Copy the bitmap data into the provided BYTE buffer
  1815. GetDIBits(hScrDC, hBmp, 0, nHeight, pData, pHeader^, DIB_RGB_COLORS);
  1816. // clean up
  1817. DeleteDC(hScrDC);
  1818. DeleteDC(hMemDC);
  1819. // return handle to the bitmap
  1820. Result := hBmp;
  1821. end;
  1822. // *****************************************************************************
  1823. // TSysDevEnum
  1824. // *****************************************************************************
  1825. procedure TSysDevEnum.GetCat(catlist: TList; CatGUID: TGUID);
  1826. var
  1827. SysDevEnum : ICreateDevEnum;
  1828. EnumCat : IEnumMoniker;
  1829. Moniker : IMoniker;
  1830. Fetched : ULONG;
  1831. PropBag : IPropertyBag;
  1832. Name : olevariant;
  1833. hr : HRESULT;
  1834. i : integer;
  1835. begin
  1836. if catList.Count > 0 then
  1837. for i := 0 to (catList.Count - 1) do if assigned(catList.Items[i]) then Dispose(catList.Items[i]);
  1838. catList.Clear;
  1839. CocreateInstance(CLSID_SystemDeviceEnum, nil, CLSCTX_INPROC, IID_ICreateDevEnum, SysDevEnum);
  1840. hr := SysDevEnum.CreateClassEnumerator(CatGUID, EnumCat, 0);
  1841. if (hr = S_OK) then
  1842. begin
  1843. while(EnumCat.Next(1, Moniker, @Fetched) = S_OK) do
  1844. begin
  1845. Moniker.BindToStorage(nil, nil, IID_IPropertyBag, PropBag);
  1846. new(ACategory);
  1847. PropBag.Read('FriendlyName', Name, nil);
  1848. ACategory^.FriendlyName := Name;
  1849. if (PropBag.Read('CLSID',Name,nil) = S_OK) then
  1850. ACategory^.CLSID := StringToGUID(Name)
  1851. else
  1852. ACategory^.CLSID := GUID_NULL;
  1853. catlist.Add(ACategory);
  1854. PropBag := nil;
  1855. Moniker := nil;
  1856. end;
  1857. end;
  1858. EnumCat :=nil;
  1859. SysDevEnum :=nil;
  1860. end;
  1861. constructor TSysDevEnum.Create;
  1862. begin
  1863. FCategories := TList.Create;
  1864. FFilters := TList.Create;
  1865. getcat(FCategories,CLSID_ActiveMovieCategories);
  1866. end;
  1867. constructor TSysDevEnum.create(guid: TGUID);
  1868. begin
  1869. FCategories := TList.Create;
  1870. FFilters := TList.Create;
  1871. getcat(FCategories,CLSID_ActiveMovieCategories);
  1872. SelectGUIDCategory(guid);
  1873. end;
  1874. destructor TSysDevEnum.Destroy;
  1875. var i: integer;
  1876. begin
  1877. inherited Destroy;
  1878. if FCategories.Count > 0 then
  1879. for i := 0 to (FCategories.Count - 1) do
  1880. if assigned(FCategories.Items[i]) then Dispose(FCategories.items[i]);
  1881. FCategories.Clear;
  1882. FreeAndNil(FCategories);
  1883. if FFilters.Count > 0 then
  1884. for i := 0 to (FFilters.Count - 1) do
  1885. if assigned(FFilters.Items[i]) then Dispose(FFilters.Items[i]);
  1886. FFilters.Clear;
  1887. FreeAndNil(FFilters);
  1888. end;
  1889. function TSysDevEnum.GetCategory(item: integer): TFilCatNode;
  1890. var PCategory: PFilCatNode;
  1891. begin
  1892. PCategory := FCategories.Items[item];
  1893. result := PCategory^;
  1894. end;
  1895. function TSysDevEnum.GetFilter(item: integer): TFilCatNode;
  1896. var PCategory: PFilCatNode;
  1897. begin
  1898. PCategory := FFilters.Items[item];
  1899. result := PCategory^;
  1900. end;
  1901. function TSysDevEnum.GetCountCategories: integer;
  1902. begin
  1903. result := FCategories.Count;
  1904. end;
  1905. function TSysDevEnum.GetCountFilters: integer;
  1906. begin
  1907. result := FFilters.Count;
  1908. end;
  1909. // Find filter index by FriendlyName; -1, if not found
  1910. function TSysDevEnum.FilterIndexOfFriendlyName(const FriendlyName: string): Integer;
  1911. begin
  1912. Result := FFilters.Count - 1;
  1913. while (Result >= 0) and
  1914. (AnsiCompareText(PFilCatNode(FFilters.Items[Result])^.FriendlyName, FriendlyName) <> 0) do
  1915. Dec(Result);
  1916. end;
  1917. procedure TSysDevEnum.SelectGUIDCategory(GUID: TGUID);
  1918. begin
  1919. FGUID := GUID;
  1920. getcat(FFilters,FGUID);
  1921. end;
  1922. procedure TSysDevEnum.SelectIndexCategory(index: integer);
  1923. begin
  1924. SelectGUIDCategory(Categories[index].CLSID);
  1925. end;
  1926. function TSysDevEnum.GetMoniker(index: integer): IMoniker;
  1927. var
  1928. SysDevEnum : ICreateDevEnum;
  1929. EnumCat : IEnumMoniker;
  1930. begin
  1931. result := nil;
  1932. if ((index < CountFilters) and (index >= 0)) then
  1933. begin
  1934. CocreateInstance(CLSID_SystemDeviceEnum, nil, CLSCTX_INPROC, IID_ICreateDevEnum, SysDevEnum);
  1935. SysDevEnum.CreateClassEnumerator(FGUID, EnumCat, 0);
  1936. EnumCat.Skip(index);
  1937. EnumCat.Next(1, Result, nil);
  1938. EnumCat.Reset;
  1939. SysDevEnum := nil;
  1940. EnumCat := nil;
  1941. end
  1942. end;
  1943. function TSysDevEnum.GetBaseFilter(index: integer): IBaseFilter;
  1944. var
  1945. SysDevEnum : ICreateDevEnum;
  1946. EnumCat : IEnumMoniker;
  1947. Moniker : IMoniker;
  1948. begin
  1949. result := nil;
  1950. if ((index < CountFilters) and (index >= 0)) then
  1951. begin
  1952. CocreateInstance(CLSID_SystemDeviceEnum, nil, CLSCTX_INPROC, IID_ICreateDevEnum, SysDevEnum);
  1953. SysDevEnum.CreateClassEnumerator(FGUID, EnumCat, 0);
  1954. EnumCat.Skip(index);
  1955. EnumCat.Next(1, Moniker, nil);
  1956. Moniker.BindToObject(nil, nil, IID_IBaseFilter, result);
  1957. EnumCat.Reset;
  1958. SysDevEnum := nil;
  1959. EnumCat := nil;
  1960. Moniker := nil;
  1961. end
  1962. end;
  1963. function TSysDevEnum.GetBaseFilter(GUID: TGUID): IBaseFilter;
  1964. var
  1965. i: integer;
  1966. begin
  1967. result := nil;
  1968. if countFilters > 0 then
  1969. for i := 0 to CountFilters - 1 do
  1970. if IsEqualGUID(GUID,Filters[i].CLSID) then
  1971. begin
  1972. result := GetBaseFilter(i);
  1973. exit;
  1974. end;
  1975. end;
  1976. //******************************************************************************
  1977. //
  1978. // TMediaType implementation
  1979. //
  1980. //******************************************************************************
  1981. destructor TMediaType.Destroy;
  1982. begin
  1983. FreeMediaType(AMMediaType);
  1984. dispose(AMMediaType);
  1985. inherited Destroy;
  1986. end;
  1987. // copy constructor does a deep copy of the format block
  1988. constructor TMediaType.Create;
  1989. begin
  1990. InitMediaType;
  1991. end;
  1992. constructor TMediaType.Create(majortype: TGUID);
  1993. begin
  1994. InitMediaType;
  1995. AMMediaType.majortype := majortype;
  1996. end;
  1997. constructor TMediaType.Create(mediatype: PAMMediaType);
  1998. begin
  1999. InitMediaType;
  2000. CopyMediaType(AMMediaType, mediatype);
  2001. end;
  2002. constructor TMediaType.Create(MTClass: TMediaType);
  2003. begin
  2004. InitMediaType;
  2005. CopyMediaType(AMMediaType, MTClass.AMMediaType);
  2006. end;
  2007. procedure TMediaType.DefineProperties(Filer: TFiler);
  2008. function DoWrite: Boolean;
  2009. begin
  2010. result := true;
  2011. if Filer.Ancestor <> nil then
  2012. begin
  2013. Result := True;
  2014. if Filer.Ancestor is TMediaType then
  2015. Result := not Equal(TMediaType(Filer.Ancestor))
  2016. end;
  2017. end;
  2018. begin
  2019. Filer.DefineBinaryProperty('data', ReadData, WriteData, DoWrite);
  2020. end;
  2021. procedure TMediaType.ReadData(Stream: TStream);
  2022. begin
  2023. ResetFormatBuffer;
  2024. Stream.Read(AMMediaType^, SizeOf(TAMMediaType));
  2025. if FormatLength > 0 then
  2026. begin
  2027. AMMediaType.pbFormat := CoTaskMemAlloc(FormatLength);
  2028. Stream.Read(AMMediaType.pbFormat^, FormatLength)
  2029. end;
  2030. end;
  2031. procedure TMediaType.WriteData(Stream: TStream);
  2032. begin
  2033. Stream.Write(AMMediaType^, SizeOf(TAMMediaType));
  2034. if FormatLength > 0 then
  2035. Stream.Write(AMMediaType.pbFormat^, FormatLength);
  2036. end;
  2037. // copy MTClass.AMMediaType to current AMMediaType
  2038. procedure TMediaType.Assign(Source: TPersistent);
  2039. begin
  2040. if Source is TMediaType then
  2041. begin
  2042. if (Source <> self) then
  2043. begin
  2044. FreeMediaType(AMMediaType);
  2045. CopyMediaType(AMMediaType, TMediaType(Source).AMMediaType);
  2046. end;
  2047. end
  2048. else
  2049. inherited Assign(Source);
  2050. end;
  2051. // this class inherits publicly from AM_MEDIA_TYPE so the compiler could generate
  2052. // the following assignment operator itself, however it could introduce some
  2053. // memory conflicts and leaks in the process because the structure contains
  2054. // a dynamically allocated block (pbFormat) which it will not copy correctly
  2055. procedure TMediaType.Read(mediatype: PAMMediaType);
  2056. begin
  2057. if (mediatype <> self.AMMediaType) then
  2058. begin
  2059. FreeMediaType(AMMediaType);
  2060. CopyMediaType(AMMediaType, mediatype);
  2061. end;
  2062. end;
  2063. function TMediaType.Equal(MTClass: TMediaType): boolean;
  2064. begin
  2065. // I don't believe we need to check sample size or
  2066. // temporal compression flags, since I think these must
  2067. // be represented in the type, subtype and format somehow. They
  2068. // are pulled out as separate flags so that people who don't understand
  2069. // the particular format representation can still see them, but
  2070. // they should duplicate information in the format block.
  2071. result := ((IsEqualGUID(AMMediaType.majortype,MTClass.AMMediaType.majortype) = TRUE) and
  2072. (IsEqualGUID(AMMediaType.subtype,MTClass.AMMediaType.subtype) = TRUE) and
  2073. (IsEqualGUID(AMMediaType.formattype,MTClass.AMMediaType.formattype) = TRUE) and
  2074. (AMMediaType.cbFormat = MTClass.AMMediaType.cbFormat) and
  2075. ( (AMMediaType.cbFormat = 0) or
  2076. (CompareMem(AMMediaType.pbFormat, MTClass.AMMediaType.pbFormat, AMMediaType.cbFormat))));
  2077. end;
  2078. // Check to see if they are equal
  2079. function TMediaType.NotEqual(MTClass: TMediaType): boolean;
  2080. begin
  2081. if (self = MTClass) then
  2082. result := FALSE
  2083. else
  2084. result := TRUE;
  2085. end;
  2086. // By default, TDSMediaType objects are initialized with a major type of GUID_NULL.
  2087. // Call this method to determine whether the object has been correctly initialized.
  2088. function TMediaType.IsValid: boolean;
  2089. begin
  2090. result := not IsEqualGUID(AMMediaType.majortype,GUID_NULL);
  2091. end;
  2092. // Determines if the samples have a fixed size or a variable size.
  2093. function TMediaType.IsFixedSize: boolean;
  2094. begin
  2095. result := AMMediaType.bFixedSizeSamples;
  2096. end;
  2097. // Determines if the stream uses temporal compression.
  2098. function TMediaType.IsTemporalCompressed: boolean;
  2099. begin
  2100. result := AMMediaType.bTemporalCompression;
  2101. end;
  2102. // If the sample size is fixed, returns the sample size in bytes. Otherwise,
  2103. // returns zero.
  2104. function TMediaType.GetSampleSize: ULONG;
  2105. begin
  2106. if IsFixedSize then
  2107. result := AMMediaType.lSampleSize
  2108. else
  2109. result := 0;
  2110. end;
  2111. // If value of sz is zero, the media type uses variable sample sizes. Otherwise,
  2112. // the sample size is fixed at sz bytes.
  2113. procedure TMediaType.SetSampleSize(SZ: ULONG);
  2114. begin
  2115. if (sz = 0) then
  2116. begin
  2117. SetVariableSize;
  2118. end
  2119. else
  2120. begin
  2121. AMMediaType.bFixedSizeSamples := TRUE;
  2122. AMMediaType.lSampleSize := sz;
  2123. end;
  2124. end;
  2125. // Specifies that samples do not have a fixed size.
  2126. procedure TMediaType.SetVariableSize;
  2127. begin
  2128. AMMediaType.bFixedSizeSamples := FALSE;
  2129. end;
  2130. // Specifies whether samples are compressed using temporal compression
  2131. procedure TMediaType.SetTemporalCompression(bCompressed: boolean);
  2132. begin
  2133. AMMediaType.bTemporalCompression := bCompressed;
  2134. end;
  2135. // Retrieves a pointer to the format block.
  2136. function TMediaType.Format: pointer;
  2137. begin
  2138. result := AMMediaType.pbFormat;
  2139. end;
  2140. //Retrieves the length of the format block.
  2141. function TMediaType.FormatLength: ULONG;
  2142. begin
  2143. result := AMMediaType.cbFormat;
  2144. end;
  2145. function TMediaType.SetFormat(pFormat: pointer; length: ULONG): boolean;
  2146. begin
  2147. if (nil = AllocFormatBuffer(length)) then
  2148. begin
  2149. result := false;
  2150. exit;
  2151. end;
  2152. ASSERT(AMMediatype.pbFormat<>nil);
  2153. CopyMemory(AMMediatype.pbFormat,pFormat,length);
  2154. result := true;
  2155. end;
  2156. // reset the format buffer
  2157. procedure TMediaType.ResetFormatBuffer;
  2158. begin
  2159. if (AMMediaType.cbFormat <> 0) then
  2160. CoTaskMemFree(AMMediaType.pbFormat);
  2161. AMMediaType.cbFormat := 0;
  2162. AMMediaType.pbFormat := nil;
  2163. end;
  2164. // allocate length bytes for the format and return a read/write pointer
  2165. // If we cannot allocate the new block of memory we return NULL leaving
  2166. // the original block of memory untouched (as does ReallocFormatBuffer)
  2167. function TMediaType.AllocFormatBuffer(length: ULONG): pointer;
  2168. var pNewFormat : pointer;
  2169. begin
  2170. ASSERT(length<>0);
  2171. // do the types have the same buffer size
  2172. if (AMMediaType.cbFormat = length) then
  2173. begin
  2174. result := AMMediaType.pbFormat;
  2175. exit;
  2176. end;
  2177. // allocate the new format buffer
  2178. pNewFormat := CoTaskMemAlloc(length);
  2179. if (pNewFormat = nil) then
  2180. begin
  2181. if (length <= AMMediaType.cbFormat) then
  2182. begin
  2183. result := AMMediatype.pbFormat; //reuse the old block anyway.
  2184. exit;
  2185. end
  2186. else
  2187. begin
  2188. result := nil;
  2189. exit;
  2190. end;
  2191. end;
  2192. // delete the old format
  2193. if (AMMediaType.cbFormat <> 0) then
  2194. begin
  2195. ASSERT(AMMediaType.pbFormat<>nil);
  2196. CoTaskMemFree(AMMediaType.pbFormat);
  2197. end;
  2198. AMMediaType.cbFormat := length;
  2199. AMMediaType.pbFormat := pNewFormat;
  2200. result := AMMediaType.pbFormat;
  2201. end;
  2202. // reallocate length bytes for the format and return a read/write pointer
  2203. // to it. We keep as much information as we can given the new buffer size
  2204. // if this fails the original format buffer is left untouched. The caller
  2205. // is responsible for ensuring the size of memory required is non zero
  2206. function TMediaType.ReallocFormatBuffer(length: ULONG): pointer;
  2207. var pNewFormat: pointer;
  2208. begin
  2209. ASSERT(length<>0);
  2210. // do the types have the same buffer size
  2211. if (AMMediaType.cbFormat = length) then
  2212. begin
  2213. result := AMMediaType.pbFormat;
  2214. exit;
  2215. end;
  2216. // allocate the new format buffer
  2217. pNewFormat := CoTaskMemAlloc(length);
  2218. if (pNewFormat = nil) then
  2219. begin
  2220. if (length <= AMMediaType.cbFormat) then
  2221. begin
  2222. result := AMMediaType.pbFormat; //reuse the old block anyway.
  2223. exit;
  2224. end
  2225. else
  2226. begin
  2227. result := nil;
  2228. exit;
  2229. end;
  2230. end;
  2231. // copy any previous format (or part of if new is smaller)
  2232. // delete the old format and replace with the new one
  2233. if (AMMediaType.cbFormat <> 0) then
  2234. begin
  2235. ASSERT(AMMediaType.pbFormat<>nil);
  2236. CopyMemory(pNewFormat, AMMediaType.pbFormat, min(length,AMMediaType.cbFormat));
  2237. CoTaskMemFree(AMMediaType.pbFormat);
  2238. end;
  2239. AMMediaType.cbFormat := length;
  2240. AMMediaType.pbFormat := pNewFormat;
  2241. result := pNewFormat;
  2242. end;
  2243. // initialise a media type structure
  2244. procedure TMediaType.InitMediaType;
  2245. begin
  2246. new(AMMediaType);
  2247. ZeroMemory(AMMediaType, sizeof(TAMMediaType));
  2248. AMMediaType.lSampleSize := 1;
  2249. AMMediaType.bFixedSizeSamples := TRUE;
  2250. end;
  2251. //Determines if this media type matches a partially specified media type.
  2252. function TMediaType.MatchesPartial(ppartial: TMediaType): boolean;
  2253. begin
  2254. if (not IsEqualGUID(ppartial.AMMediaType.majortype, GUID_NULL) and
  2255. not IsEqualGUID(AMMediaType.majortype, ppartial.AMMediaType.majortype)) then
  2256. begin
  2257. result := false;
  2258. exit;
  2259. end;
  2260. if (not IsEqualGUID(ppartial.AMMediaType.subtype, GUID_NULL) and
  2261. not IsEqualGUID(AMMediaType.subtype, ppartial.AMMediaType.subtype)) then
  2262. begin
  2263. result := false;
  2264. exit;
  2265. end;
  2266. if not IsEqualGUID(ppartial.AMMediaType.formattype, GUID_NULL) then
  2267. begin
  2268. // if the format block is specified then it must match exactly
  2269. if not IsEqualGUID(AMMediaType.formattype, ppartial.AMMediaType.formattype) then
  2270. begin
  2271. result := FALSE;
  2272. exit;
  2273. end;
  2274. if (AMMediaType.cbFormat <> ppartial.AMMediaType.cbFormat) then
  2275. begin
  2276. result := FALSE;
  2277. exit;
  2278. end;
  2279. if ((AMMediaType.cbFormat <> 0) and
  2280. (CompareMem(AMMediaType.pbFormat, ppartial.AMMediaType.pbFormat, AMMediaType.cbFormat) <> false)) then
  2281. begin
  2282. result := FALSE;
  2283. exit;
  2284. end;
  2285. end;
  2286. result := TRUE;
  2287. end;
  2288. // a partially specified media type can be passed to IPin::Connect
  2289. // as a constraint on the media type used in the connection.
  2290. // the type, subtype or format type can be null.
  2291. function TMediaType.IsPartiallySpecified: boolean;
  2292. begin
  2293. if (IsEqualGUID(AMMediaType.majortype, GUID_NULL) or
  2294. IsEqualGUID(AMMediaType.formattype, GUID_NULL)) then
  2295. begin
  2296. result := TRUE;
  2297. exit;
  2298. end
  2299. else
  2300. begin
  2301. result := FALSE;
  2302. exit;
  2303. end;
  2304. end;
  2305. function TMediaType.GetMajorType: TGUID;
  2306. begin
  2307. result := AMMediaType.majortype;
  2308. end;
  2309. procedure TMediaType.SetMajorType(MT: TGUID);
  2310. begin
  2311. AMMediaType.majortype := MT;
  2312. end;
  2313. function TMediaType.GetSubType: TGUID;
  2314. begin
  2315. result := AMMediaType.subtype;
  2316. end;
  2317. procedure TMediaType.SetSubType(ST: TGUID);
  2318. begin
  2319. AMMediaType.subtype := ST;
  2320. end;
  2321. // set the type of the media type format block, this type defines what you
  2322. // will actually find in the format pointer. For example FORMAT_VideoInfo or
  2323. // FORMAT_WaveFormatEx. In the future this may be an interface pointer to a
  2324. // property set. Before sending out media types this should be filled in.
  2325. procedure TMediaType.SetFormatType(const GUID: TGUID);
  2326. begin
  2327. AMMediaType.formattype := GUID;
  2328. end;
  2329. function TMediaType.GetFormatType: TGUID;
  2330. begin
  2331. result := AMMediaType.formattype;
  2332. end;
  2333. //******************************************************************************
  2334. //
  2335. // TDSEnumMediaType Implementation
  2336. //
  2337. //******************************************************************************
  2338. constructor TEnumMediaType.Create;
  2339. begin
  2340. FList := TList.Create;
  2341. end;
  2342. constructor TEnumMediaType.Create(Pin: IPin);
  2343. var EnumMT : IEnumMediaTypes;
  2344. hr : HRESULT;
  2345. begin
  2346. FList := TList.Create;
  2347. assert(pin <> nil,'IPin not assigned');
  2348. hr := pin.EnumMediaTypes(EnumMT);
  2349. if (hr <> S_OK) then exit;
  2350. Create(ENumMT);
  2351. end;
  2352. constructor TEnumMediaType.Create(EnumMT: IEnumMediaTypes);
  2353. var pmt: PAMMediaType;
  2354. begin
  2355. if (FList = nil) then FList := TList.Create;
  2356. assert(EnumMT <> nil,'IEnumMediaType not assigned');
  2357. while (EnumMT.Next(1,pmt,nil)= S_OK) do
  2358. begin
  2359. FList.Add(TMediaType.Create(pmt));
  2360. end;
  2361. end;
  2362. constructor TEnumMediaType.Create(FileName: TFileName);
  2363. begin
  2364. FList := TList.Create;
  2365. Assign(FileName);
  2366. end;
  2367. destructor TEnumMediaType.Destroy;
  2368. begin
  2369. Clear;
  2370. FList.Free;
  2371. end;
  2372. procedure TEnumMediaType.Assign(Pin: IPin);
  2373. var EnumMT : IEnumMediaTypes;
  2374. hr : HRESULT;
  2375. begin
  2376. Clear;
  2377. assert(pin <> nil,'IPin not assigned');
  2378. hr := pin.EnumMediaTypes(EnumMT);
  2379. if (hr <> S_OK) then exit;
  2380. Assign(ENumMT);
  2381. end;
  2382. procedure TEnumMediaType.Assign(EnumMT: IEnumMediaTypes);
  2383. var pmt: PAMMediaType;
  2384. begin
  2385. if (count <> 0) then Clear;
  2386. assert(EnumMT <> nil,'IEnumMediaType not assigned');
  2387. while (EnumMT.Next(1,pmt,nil)= S_OK) do
  2388. begin
  2389. FList.Add(TMediaType.Create(pmt));
  2390. end;
  2391. end;
  2392. procedure TEnumMediaType.Assign(FileName: TFileName);
  2393. var
  2394. MediaDet: IMediaDet;
  2395. KeyProvider : IServiceProvider;
  2396. hr: HRESULT;
  2397. Streams: LongInt;
  2398. i: longint;
  2399. MediaType: TAMMediaType;
  2400. begin
  2401. Clear;
  2402. hr := CoCreateInstance(CLSID_MediaDet, nil, CLSCTX_INPROC, IID_IMediaDet, MediaDet);
  2403. // milenko start get rid of compiler warnings ...
  2404. if (hr = S_OK) then
  2405. begin
  2406. end;
  2407. // milenko end;
  2408. assert(hr = S_OK, 'Media Detector not available');
  2409. hr := MediaDet.put_Filename(FileName);
  2410. if hr <> S_OK then
  2411. begin
  2412. MediaDet := nil;
  2413. Exit;
  2414. end;
  2415. MediaDet.get_OutputStreams(Streams);
  2416. if streams > 0 then
  2417. begin
  2418. for i := 0 to (streams - 1) do
  2419. begin
  2420. MediaDet.put_CurrentStream(i);
  2421. MediaDet.get_StreamMediaType(MediaType);
  2422. FList.Add(TMediaType.Create(@MediaType));
  2423. end;
  2424. end;
  2425. KeyProvider := nil;
  2426. MediaDet := nil;
  2427. end;
  2428. function TEnumMediaType.GetItem(Index: Integer): TMediaType;
  2429. begin
  2430. result := TMediaType(Flist.Items[index]);
  2431. end;
  2432. function TEnumMediaType.GetMediaDescription(Index: Integer): string;
  2433. begin
  2434. result := '';
  2435. if ((index < count) and (index > -1)) then
  2436. result := GetMediaTypeDescription(TMediaType(Flist.Items[index]).AMMediaType);
  2437. end;
  2438. procedure TEnumMediaType.SetItem(Index: Integer; Item: TMediaType);
  2439. begin
  2440. TMediaType(Flist.Items[index]).Assign(item);
  2441. end;
  2442. function TEnumMediaType.GetCount: integer;
  2443. begin
  2444. assert(FList<>nil,'TDSEnumMediaType not created');
  2445. if (FList <> nil) then
  2446. result := FList.Count
  2447. else
  2448. result := 0;
  2449. end;
  2450. function TEnumMediaType.Add(Item: TMediaType): Integer;
  2451. begin
  2452. result := FList.Add(Item);
  2453. end;
  2454. procedure TEnumMediaType.Clear;
  2455. var i: Integer;
  2456. begin
  2457. if count <> 0 then
  2458. for i := 0 to (count -1) do
  2459. begin
  2460. if (FList.Items[i]<>nil) then TMediaType(FList.Items[i]).Free;
  2461. end;
  2462. FList.Clear;
  2463. end;
  2464. procedure TEnumMediaType.Delete(Index: Integer);
  2465. begin
  2466. if (FList.Items[index]<>nil) then TMediaType(FList.Items[index]).Free;
  2467. FList.Delete(index);
  2468. end;
  2469. // *****************************************************************************
  2470. // TDSFilterList implementation
  2471. // *****************************************************************************
  2472. constructor TFilterList.Create(FilterGraph: IFilterGraph);
  2473. begin
  2474. inherited Create;
  2475. Graph := FilterGraph;
  2476. Update;
  2477. end;
  2478. destructor TFilterList.Destroy;
  2479. begin
  2480. inherited Destroy;
  2481. end;
  2482. procedure TFilterList.Update;
  2483. var EnumFilters: IEnumFilters;
  2484. Filter: IBaseFilter;
  2485. begin
  2486. if assigned(Graph) then
  2487. Graph.EnumFilters(EnumFilters);
  2488. while (EnumFilters.Next(1, Filter, nil) = S_OK) do add(Filter);
  2489. EnumFilters := nil;
  2490. end;
  2491. procedure TFilterList.Assign(FilterGraph: IFilterGraph);
  2492. begin
  2493. Clear;
  2494. Graph := FilterGraph;
  2495. Update;
  2496. end;
  2497. function TFilterList.GetFilter(Index: Integer): IBaseFilter;
  2498. begin
  2499. result := get(index) as IBaseFilter;
  2500. end;
  2501. procedure TFilterList.PutFilter(Index: Integer; Item: IBaseFilter);
  2502. begin
  2503. put(index,Item);
  2504. end;
  2505. function TFilterList.First: IBaseFilter;
  2506. begin
  2507. result := GetFilter(0);
  2508. end;
  2509. function TFilterList.IndexOf(Item: IBaseFilter): Integer;
  2510. begin
  2511. result := inherited IndexOf(Item);
  2512. end;
  2513. function TFilterList.Add(Item: IBaseFilter): Integer;
  2514. begin
  2515. result := inherited Add(Item);
  2516. end;
  2517. procedure TFilterList.Insert(Index: Integer; Item: IBaseFilter);
  2518. begin
  2519. inherited Insert(index,item);
  2520. end;
  2521. function TFilterList.Last: IBaseFilter;
  2522. begin
  2523. result := inherited Last as IBaseFilter;
  2524. end;
  2525. function TFilterList.Remove(Item: IBaseFilter): Integer;
  2526. begin
  2527. result := inherited Remove(Item);
  2528. end;
  2529. function TFilterList.GetFilterInfo(index: integer): TFilterInfo;
  2530. begin
  2531. if assigned(items[index]) then items[index].QueryFilterInfo(result);
  2532. end;
  2533. // *****************************************************************************
  2534. // TPinList
  2535. // *****************************************************************************
  2536. constructor TPinList.Create(BaseFilter: IBaseFilter);
  2537. begin
  2538. inherited Create;
  2539. Filter := BaseFilter;
  2540. Update;
  2541. end;
  2542. destructor TPinList.Destroy;
  2543. begin
  2544. Filter := nil;
  2545. inherited Destroy;
  2546. end;
  2547. procedure TPinList.Update;
  2548. var
  2549. EnumPins : IEnumPins;
  2550. Pin : IPin;
  2551. begin
  2552. clear;
  2553. if assigned(Filter) then Filter.EnumPins(EnumPins) else exit;
  2554. while (EnumPins.Next(1, pin, nil) = S_OK) do add(Pin);
  2555. EnumPins := nil;
  2556. end;
  2557. procedure TPinList.Assign(BaseFilter: IBaseFilter);
  2558. begin
  2559. Clear;
  2560. Filter := BaseFilter;
  2561. if Filter <> nil then Update;
  2562. end;
  2563. function TPinList.GetConnected(Index: Integer): boolean;
  2564. var Pin: IPin;
  2565. begin
  2566. Items[Index].ConnectedTo(Pin);
  2567. Result := (Pin <> nil);
  2568. end;
  2569. function TPinList.GetPin(Index: Integer): IPin;
  2570. begin
  2571. result := get(index) as IPin;
  2572. end;
  2573. procedure TPinList.PutPin(Index: Integer; Item: IPin);
  2574. begin
  2575. put(index,Item);
  2576. end;
  2577. function TPinList.First: IPin;
  2578. begin
  2579. result := GetPin(0);
  2580. end;
  2581. function TPinList.IndexOf(Item: IPin): Integer;
  2582. begin
  2583. result := inherited IndexOf(Item);
  2584. end;
  2585. function TPinList.Add(Item: IPin): Integer;
  2586. begin
  2587. result := inherited Add(Item);
  2588. end;
  2589. procedure TPinList.Insert(Index: Integer; Item: IPin);
  2590. begin
  2591. inherited Insert(index,item);
  2592. end;
  2593. function TPinList.Last: IPin;
  2594. begin
  2595. result := inherited Last as IPin;
  2596. end;
  2597. function TPinList.Remove(Item: IPin): Integer;
  2598. begin
  2599. result := inherited Remove(Item);
  2600. end;
  2601. function TPinList.GetPinInfo(index: integer): TPinInfo;
  2602. begin
  2603. if assigned(Items[index]) then Items[index].QueryPinInfo(result);
  2604. end;
  2605. // *****************************************************************************
  2606. // TPersistentMemory
  2607. // *****************************************************************************
  2608. constructor TPersistentMemory.Create;
  2609. begin
  2610. FData := nil;
  2611. FDataLength := 0;
  2612. end;
  2613. destructor TPersistentMemory.Destroy;
  2614. begin
  2615. AllocateMemory(0);
  2616. inherited destroy;
  2617. end;
  2618. procedure TPersistentMemory.AllocateMemory(ALength: Cardinal);
  2619. begin
  2620. if (FDataLength > 0) and (FData <> nil) then
  2621. begin
  2622. FreeMem(FData, FDataLength);
  2623. FData := nil;
  2624. FDataLength := 0;
  2625. end;
  2626. if ALength > 0 then
  2627. begin
  2628. GetMem(FData, ALength);
  2629. ZeroMemory(FData, ALength);
  2630. FDataLength := ALength;
  2631. end
  2632. end;
  2633. procedure TPersistentMemory.ReadData(Stream: TStream);
  2634. var ALength: Cardinal;
  2635. begin
  2636. Stream.Read(ALength, SizeOf(Cardinal));
  2637. AllocateMemory(ALength);
  2638. if ALength > 0 then
  2639. Stream.Read(FData^, ALength);
  2640. end;
  2641. procedure TPersistentMemory.WriteData(Stream: TStream);
  2642. begin
  2643. Stream.Write(FDataLength, SizeOf(Cardinal));
  2644. if FDataLength > 0 then
  2645. Stream.Write(FData^, FDataLength);
  2646. end;
  2647. procedure TPersistentMemory.Assign(Source: TPersistent);
  2648. begin
  2649. if Source is TPersistentMemory then
  2650. begin
  2651. if (Source <> self) then
  2652. begin
  2653. AllocateMemory(TPersistentMemory(Source).FDataLength);
  2654. if FDataLength > 0 then
  2655. move(TPersistentMemory(Source).FData^, FData^, FDataLength);
  2656. end;
  2657. end
  2658. else
  2659. inherited Assign(Source);
  2660. end;
  2661. procedure TPersistentMemory.AssignTo(Dest: TPersistent);
  2662. begin
  2663. Dest.Assign(self);
  2664. end;
  2665. function TPersistentMemory.Equal(Memory: TPersistentMemory): boolean;
  2666. begin
  2667. result := false;
  2668. if (Memory.FDataLength > 0) and (Memory.FDataLength = FDataLength) and
  2669. (Memory.FData <> nil) and (FData <> nil) then
  2670. result := comparemem(Memory.FData, FData, FDataLength);
  2671. end;
  2672. procedure TPersistentMemory.DefineProperties(Filer: TFiler);
  2673. function DoWrite: Boolean;
  2674. begin
  2675. result := true;
  2676. if Filer.Ancestor <> nil then
  2677. begin
  2678. Result := True;
  2679. if Filer.Ancestor is TPersistentMemory then
  2680. Result := not Equal(TPersistentMemory(Filer.Ancestor))
  2681. end;
  2682. end;
  2683. begin
  2684. Filer.DefineBinaryProperty('data', ReadData, WriteData, DoWrite);
  2685. end;
  2686. // *****************************************************************************
  2687. // TBaseFilter
  2688. // *****************************************************************************
  2689. procedure TBaseFilter.SetMoniker(Moniker: IMoniker);
  2690. var
  2691. MemStream : TMemoryStream;
  2692. AdaStream : TStreamAdapter;
  2693. begin
  2694. if Moniker = nil then
  2695. begin
  2696. DataLength := 0;
  2697. exit;
  2698. end;
  2699. MemStream := TMemoryStream.Create;
  2700. AdaStream := TStreamAdapter.Create(MemStream, soReference);
  2701. OleSaveToStream(Moniker, AdaStream);
  2702. DataLength := MemStream.Size;
  2703. move(MemStream.Memory^, Data^, DataLength);
  2704. AdaStream.Free;
  2705. MemStream.Free;
  2706. end;
  2707. function TBaseFilter.GetMoniker: IMoniker;
  2708. var
  2709. MemStream : TMemoryStream;
  2710. AdaStream : TStreamAdapter;
  2711. begin
  2712. if DataLength > 0 then
  2713. begin
  2714. MemStream := TMemoryStream.Create;
  2715. MemStream.SetSize(DataLength);
  2716. move(Data^, MemStream.Memory^, DataLength);
  2717. AdaStream := TStreamAdapter.Create(MemStream, soReference);
  2718. OleLoadFromStream(AdaStream, IMoniker, result);
  2719. AdaStream.Free;
  2720. MemStream.Free;
  2721. end
  2722. else
  2723. result := nil;
  2724. end;
  2725. function TBaseFilter.CreateFilter: IBaseFilter;
  2726. var
  2727. AMoniker : IMoniker;
  2728. begin
  2729. AMoniker := Moniker;
  2730. if AMoniker <> nil then
  2731. begin
  2732. AMoniker.BindToObject(nil, nil, IBaseFilter, result);
  2733. AMoniker := nil;
  2734. end
  2735. else
  2736. result := nil;
  2737. end;
  2738. function TBaseFilter.PropertyBag(Name: WideString): OleVariant;
  2739. var
  2740. AMoniker : IMoniker;
  2741. PropBag : IPropertyBag;
  2742. begin
  2743. AMoniker := Moniker;
  2744. if AMoniker <> nil then
  2745. begin
  2746. AMoniker.BindToStorage(nil, nil, IID_IPropertyBag, PropBag);
  2747. if PropBag <> nil then PropBag.Read(PWideChar(Name), result, nil);
  2748. PropBag := nil;
  2749. AMoniker := nil;
  2750. end
  2751. else
  2752. result := NULL;
  2753. end;
  2754. // milenko start (added functions from dshowutil.cpp)
  2755. function FindRenderer(pGB: IGraphBuilder; const mediatype: PGUID; out ppFilter: IBaseFilter): HRESULT;
  2756. var
  2757. Enum : IEnumFilters;
  2758. Filter: IBaseFilter;
  2759. Pin : IPin;
  2760. Fetched,
  2761. InPins,
  2762. OutPins: Cardinal;
  2763. Found: Boolean;
  2764. MediaType_: TAMMediaType;
  2765. begin
  2766. Found := False;
  2767. // Verify graph builder interface
  2768. if not Assigned(pGB) then
  2769. begin
  2770. Result := E_NOINTERFACE;
  2771. Exit;
  2772. end;
  2773. // Verify that a media type was passed
  2774. if not Assigned(mediatype) then
  2775. begin
  2776. Result := E_POINTER;
  2777. Exit;
  2778. end;
  2779. // Clear the filter pointer in case there is no match
  2780. if Assigned(ppFilter) then ppFilter := nil;
  2781. // Get filter enumerator
  2782. Result := pGB.EnumFilters(Enum);
  2783. if FAILED(Result) then Exit;
  2784. Enum.Reset;
  2785. // Enumerate all filters in the graph
  2786. while((not Found) and (Enum.Next(1, Filter, @Fetched) = S_OK)) do
  2787. begin
  2788. // Find a filter with one input and no output pins
  2789. Result := CountFilterPins(Filter, InPins, OutPins);
  2790. if FAILED(Result) then break;
  2791. if ((InPins = 1) and (OutPins = 0)) then
  2792. begin
  2793. // Get the first pin on the filter
  2794. Pin := nil;
  2795. Pin := GetInPin(Filter, 0);
  2796. // Read this pin's major media type
  2797. Result := Pin.ConnectionMediaType(MediaType_);
  2798. if FAILED(Result) then break;
  2799. // Is this pin's media type the requested type?
  2800. // If so, then this is the renderer for which we are searching.
  2801. // Copy the interface pointer and return.
  2802. if IsEqualGUID(MediaType_.majortype,mediatype^) then
  2803. begin
  2804. // Found our filter
  2805. ppFilter := Filter;
  2806. Found := True;
  2807. end else
  2808. begin
  2809. // This is not the renderer, so release the interface.
  2810. Filter := nil;
  2811. end;
  2812. // Delete memory allocated by ConnectionMediaType()
  2813. UtilFreeMediaType(@MediaType_);
  2814. end else
  2815. begin
  2816. // No match, so release the interface
  2817. Filter := nil;
  2818. end;
  2819. end;
  2820. Enum := nil;
  2821. end;
  2822. function FindAudioRenderer(pGB: IGraphBuilder; out ppFilter: IBaseFilter): HRESULT;
  2823. begin
  2824. Result := FindRenderer(pGB, @MEDIATYPE_Audio, ppFilter);
  2825. end;
  2826. function FindVideoRenderer(pGB: IGraphBuilder; out ppFilter: IBaseFilter): HRESULT;
  2827. begin
  2828. Result := FindRenderer(pGB, @MEDIATYPE_Video, ppFilter);
  2829. end;
  2830. function CountFilterPins(pFilter: IBaseFilter; out pulInPins: Cardinal; out pulOutPins: Cardinal): HRESULT;
  2831. var
  2832. Enum: IEnumPins;
  2833. Found: Cardinal;
  2834. Pin: IPin;
  2835. PinDir: TPinDirection;
  2836. begin
  2837. // Verify input
  2838. if (not Assigned(pFilter) or not Assigned(@pulInPins) or not Assigned(@pulOutPins)) then
  2839. begin
  2840. Result := E_POINTER;
  2841. Exit;
  2842. end;
  2843. // Clear number of pins found
  2844. pulInPins := 0;
  2845. pulOutPins := 0;
  2846. // Get pin enumerator
  2847. Result := pFilter.EnumPins(Enum);
  2848. if FAILED(Result) then Exit;
  2849. Enum.Reset;
  2850. // Count every pin on the filter
  2851. while(S_OK = Enum.Next(1, Pin, @Found)) do
  2852. begin
  2853. Result := Pin.QueryDirection(PinDir);
  2854. if (PinDir = PINDIR_INPUT) then inc(pulInPins)
  2855. else inc(pulOutPins);
  2856. Pin := nil;
  2857. end;
  2858. Enum := nil;
  2859. end;
  2860. function CountTotalFilterPins(pFilter: IBaseFilter; out pulPins: Cardinal): HRESULT;
  2861. var
  2862. Enum: IEnumPins;
  2863. Found: Cardinal;
  2864. Pin: IPin;
  2865. begin
  2866. // Verify input
  2867. if (not Assigned(pFilter) or not Assigned(@pulPins)) then
  2868. begin
  2869. Result := E_POINTER;
  2870. Exit;
  2871. end;
  2872. // Clear number of pins found
  2873. pulPins := 0;
  2874. // Get pin enumerator
  2875. Result := pFilter.EnumPins(Enum);
  2876. if FAILED(Result) then Exit;
  2877. // Count every pin on the filter, ignoring direction
  2878. while(S_OK = Enum.Next(1, Pin, @Found)) do
  2879. begin
  2880. inc(pulPins);
  2881. Pin := nil;
  2882. end;
  2883. Enum := nil;
  2884. end;
  2885. function GetPin(pFilter: IBaseFilter; dirrequired: TPinDirection; iNum: integer; out ppPin: IPin): HRESULT;
  2886. var
  2887. Enum: IEnumPins;
  2888. Found: Cardinal;
  2889. Pin: IPin;
  2890. PinDir: TPinDirection;
  2891. begin
  2892. ppPin := nil;
  2893. if not Assigned(pFilter) then
  2894. begin
  2895. Result := E_POINTER;
  2896. Exit;
  2897. end;
  2898. Result := pFilter.EnumPins(Enum);
  2899. if FAILED(Result) then Exit;
  2900. Result := E_FAIL;
  2901. while(S_OK = Enum.Next(1, Pin, @Found)) do
  2902. begin
  2903. Pin.QueryDirection(PinDir);
  2904. if (PinDir = dirrequired) then
  2905. begin
  2906. if (iNum = 0) then
  2907. begin
  2908. ppPin := Pin; // Return the pin's interface
  2909. Result := S_OK; // Found requested pin, so clear error
  2910. break;
  2911. end;
  2912. inc(iNum);
  2913. end;
  2914. Pin := nil;
  2915. end;
  2916. Enum := nil;
  2917. end;
  2918. function GetInPin(pFilter: IBaseFilter; nPin: integer): IPin;
  2919. begin
  2920. GetPin(pFilter, PINDIR_INPUT, nPin, Result);
  2921. end;
  2922. function GetOutPin(pFilter: IBaseFilter; nPin: integer): IPin;
  2923. begin
  2924. GetPin(pFilter, PINDIR_OUTPUT, nPin, Result);
  2925. end;
  2926. function FindOtherSplitterPin(pPinIn: IPin; guid: TGUID; nStream: integer; out ppSplitPin: IPin): HRESULT;
  2927. var
  2928. PinOut: IPin;
  2929. ThisPinInfo,
  2930. pi: TPinInfo;
  2931. EnumPins: IEnumPins;
  2932. Fetched: Cardinal;
  2933. Pin: IPin;
  2934. MediaEnum: IEnumMediaTypes;
  2935. MediaType: PAMMediaType;
  2936. begin
  2937. if not Assigned(ppSplitPin) then
  2938. begin
  2939. Result := E_POINTER;
  2940. Exit;
  2941. end;
  2942. PinOut := pPinIn;
  2943. while Assigned(PinOut) do
  2944. begin
  2945. PinOut.QueryPinInfo(ThisPinInfo);
  2946. if Assigned(ThisPinInfo.pFilter) then ThisPinInfo.pFilter := nil;
  2947. PinOut := nil;
  2948. ThisPinInfo.pFilter.EnumPins(EnumPins);
  2949. if not Assigned(EnumPins) then
  2950. begin
  2951. // return NULL; ???
  2952. Result := S_FALSE;
  2953. Exit;
  2954. end;
  2955. // look at every pin on the current filter...
  2956. while True do
  2957. begin
  2958. Fetched := 0;
  2959. ASSERT(not Assigned(Pin)); // is it out of scope?
  2960. EnumPins.Next(1, Pin, @Fetched);
  2961. if not BOOL(Fetched) then break;
  2962. Pin.QueryPinInfo(pi);
  2963. if Assigned(pi.pFilter) then pi.pFilter := nil;
  2964. // if it's an input pin...
  2965. if (pi.dir = PINDIR_INPUT) then
  2966. begin
  2967. // continue searching upstream from this pin
  2968. Pin.ConnectedTo(PinOut);
  2969. // a pin that supports the required media type is the
  2970. // splitter pin we are looking for! We are done
  2971. end else
  2972. begin
  2973. Pin.EnumMediaTypes(MediaEnum);
  2974. if Assigned(MediaEnum) then
  2975. begin
  2976. Fetched := 0;
  2977. MediaEnum.Next(1, MediaType, @Fetched);
  2978. if BOOL(Fetched) then
  2979. begin
  2980. if IsEqualGUID(MediaType.majortype,guid) then
  2981. begin
  2982. dec(nStream);
  2983. if(nStream = 0) then
  2984. begin
  2985. UtilDeleteMediaType(MediaType);
  2986. ppSplitPin := Pin;
  2987. Result := S_OK;
  2988. Exit;
  2989. end;
  2990. end;
  2991. UtilDeleteMediaType(MediaType);
  2992. end;
  2993. end;
  2994. end;
  2995. // go try the next pin
  2996. end; // while
  2997. end;
  2998. ASSERT(False);
  2999. Result := E_FAIL;
  3000. end;
  3001. function SeekNextFrame(pSeeking: IMediaSeeking; FPS: Double; Frame: LongInt): HRESULT;
  3002. var
  3003. Pos: TReferenceTime;
  3004. begin
  3005. // try seeking by frames first
  3006. Pos := 0;
  3007. Result := pSeeking.SetTimeFormat(TIME_FORMAT_FRAME);
  3008. if not FAILED(Result) then
  3009. begin
  3010. pSeeking.GetCurrentPosition(Pos);
  3011. inc(Pos);
  3012. end else
  3013. begin
  3014. // couldn't seek by frames, use Frame and FPS to calculate time
  3015. Pos := Round(Frame * UNITS / FPS);
  3016. // add a half-frame to seek to middle of the frame
  3017. Pos := Pos + Round(UNITS * 0.5 / FPS);
  3018. end;
  3019. Result := pSeeking.SetPositions(Pos, AM_SEEKING_AbsolutePositioning,
  3020. Pos, AM_SEEKING_NoPositioning);
  3021. end;
  3022. procedure ShowFilenameByCLSID(clsid: TGUID; out szFilename: WideString);
  3023. begin
  3024. szFilename := '<Unknown>';
  3025. with TRegistry.Create do
  3026. begin
  3027. RootKey := HKEY_LOCAL_MACHINE;
  3028. if KeyExists('Software\Classes\CLSID\' + GUIDToString(clsid) + 'InprocServer32') then
  3029. begin
  3030. if OpenKeyReadOnly('Software\Classes\CLSID\' + GUIDToString(clsid) + 'InprocServer32') then
  3031. begin
  3032. szFilename := ReadString('');
  3033. CloseKey;
  3034. end;
  3035. end;
  3036. Free;
  3037. end;
  3038. end;
  3039. function GetFileDurationString(pMS: IMediaSeeking; out szDuration: WideString): HRESULT;
  3040. var
  3041. guidOriginalFormat: TGUID;
  3042. Duration: Int64;
  3043. TotalMS: Cardinal;
  3044. MS: integer;
  3045. Seconds: integer;
  3046. Minutes: integer;
  3047. begin
  3048. if not Assigned(pMS) then
  3049. begin
  3050. Result := E_NOINTERFACE;
  3051. Exit;
  3052. end;
  3053. if not Assigned(@szDuration) then
  3054. begin
  3055. Result := E_POINTER;
  3056. Exit;
  3057. end;
  3058. // Initialize the display in case we can't read the duration
  3059. szDuration := '<00:00.000>';
  3060. // Is media time supported for this file?
  3061. if (S_OK <> pMS.IsFormatSupported(TIME_FORMAT_MEDIA_TIME)) then
  3062. begin
  3063. Result := E_NOINTERFACE;
  3064. Exit;
  3065. end;
  3066. // Read the time format to restore later
  3067. Result := pMS.GetTimeFormat(guidOriginalFormat);
  3068. if FAILED(Result) then Exit;
  3069. // Ensure media time format for easy display
  3070. Result := pMS.SetTimeFormat(TIME_FORMAT_MEDIA_TIME);
  3071. if FAILED(Result) then Exit;
  3072. // Read the file's duration
  3073. Result := pMS.GetDuration(Duration);
  3074. if FAILED(Result) then Exit;
  3075. // Return to the original format
  3076. if not IsEqualGUID(guidOriginalFormat,TIME_FORMAT_MEDIA_TIME) then
  3077. begin
  3078. Result := pMS.SetTimeFormat(guidOriginalFormat);
  3079. if FAILED(Result) then Exit;
  3080. end;
  3081. // Convert the LONGLONG duration into human-readable format
  3082. TotalMS := Cardinal(Duration div 10000); // 100ns -> ms
  3083. MS := TotalMS mod 1000;
  3084. Seconds := TotalMS div 1000;
  3085. Minutes := Seconds div 60;
  3086. Seconds := Seconds mod 60;
  3087. // Update the string
  3088. szDuration := inttostr(Minutes) + 'm:' + inttostr(Seconds) + '.' + inttostr(MS) + 's';
  3089. end;
  3090. function CanFrameStep(pGB: IGraphBuilder): Boolean;
  3091. var
  3092. pFS: IVideoFrameStep;
  3093. hr: HRESULT;
  3094. begin
  3095. // Get frame step interface
  3096. hr := pGB.QueryInterface(IID_IVideoFrameStep, pFS);
  3097. if FAILED(hr) then
  3098. begin
  3099. Result := False;
  3100. Exit;
  3101. end;
  3102. // Check if this decoder can step
  3103. hr := pFS.CanStep(0, nil);
  3104. // Release frame step interface
  3105. pFS := nil;
  3106. Result := hr = S_OK;
  3107. end;
  3108. procedure UtilDeleteMediaType(pmt: PAMMediaType);
  3109. begin
  3110. // Allow NULL pointers for coding simplicity
  3111. if (pmt = nil) then Exit;
  3112. // Free media type's format data
  3113. if (pmt.cbFormat <> 0) then
  3114. begin
  3115. CoTaskMemFree(pmt.pbFormat);
  3116. // Strictly unnecessary but tidier
  3117. pmt.cbFormat := 0;
  3118. pmt.pbFormat := nil;
  3119. end;
  3120. // Release interface
  3121. if (pmt.pUnk <> nil) then pmt.pUnk := nil;
  3122. // Free media type
  3123. CoTaskMemFree(pmt);
  3124. end;
  3125. procedure UtilFreeMediaType(pmt: PAMMediaType);
  3126. begin
  3127. if (pmt.cbFormat <> 0) then
  3128. begin
  3129. CoTaskMemFree(pmt.pbFormat);
  3130. // Strictly unnecessary but tidier
  3131. pmt.cbFormat := 0;
  3132. pmt.pbFormat := nil;
  3133. end;
  3134. if (pmt.pUnk <> nil) then pmt.pUnk := nil;
  3135. end;
  3136. const
  3137. wszStreamName: WideString = 'ActiveMovieGraph';
  3138. function SaveGraphFile(pGraph: IGraphBuilder; wszPath: WideString): HRESULT;
  3139. var
  3140. Storage: IStorage;
  3141. Stream: IStream;
  3142. Persist: IPersistStream;
  3143. begin
  3144. Result := StgCreateDocfile(
  3145. PWideChar(wszPath),
  3146. STGM_CREATE or STGM_TRANSACTED or STGM_READWRITE or STGM_SHARE_EXCLUSIVE,
  3147. 0, Storage);
  3148. if FAILED(Result) then Exit;
  3149. Result := Storage.CreateStream(
  3150. PWideChar(wszStreamName),
  3151. STGM_WRITE or STGM_CREATE or STGM_SHARE_EXCLUSIVE,
  3152. 0, 0, Stream);
  3153. if FAILED(Result) then Exit;
  3154. pGraph.QueryInterface(IID_IPersistStream, Persist);
  3155. Result := Persist.Save(Stream, True);
  3156. Stream := nil;
  3157. Persist := nil;
  3158. if SUCCEEDED(Result) then Result := Storage.Commit(STGC_DEFAULT);
  3159. Storage := nil;
  3160. end;
  3161. function LoadGraphFile(pGraph: IGraphBuilder; const wszName: WideString): HRESULT;
  3162. var
  3163. Storage: IStorage;
  3164. Stream: IStream;
  3165. PersistStream: IPersistStream;
  3166. begin
  3167. if (S_OK <> StgIsStorageFile(PWideChar(wszName))) then
  3168. begin
  3169. Result := E_FAIL;
  3170. Exit;
  3171. end;
  3172. Result := StgOpenStorage(PWideChar(wszName), nil,
  3173. STGM_TRANSACTED or STGM_READ or STGM_SHARE_DENY_WRITE,
  3174. nil, 0, Storage);
  3175. if FAILED(Result) then Exit;
  3176. Result := pGraph.QueryInterface(IID_IPersistStream, PersistStream);
  3177. if (SUCCEEDED(Result)) then
  3178. begin
  3179. Result := Storage.OpenStream(PWideChar(wszStreamName), nil,
  3180. STGM_READ or STGM_SHARE_EXCLUSIVE, 0, Stream);
  3181. if SUCCEEDED(Result) then
  3182. begin
  3183. Result := PersistStream.Load(Stream);
  3184. Stream := nil;
  3185. end;
  3186. PersistStream := nil;
  3187. end;
  3188. Storage := nil;
  3189. end;
  3190. // milenko end
  3191. // Michael Start.
  3192. //-----------------------------------------------------------------------------
  3193. // Name: GetDXVersion()
  3194. // Desc: This function returns the DirectX version.
  3195. // Arguments:
  3196. // pdwDirectXVersion - This can be NULL. If non-NULL, the return value is:
  3197. // 0x00000000 = No DirectX installed
  3198. // 0x00010000 = DirectX 1.0 installed
  3199. // 0x00020000 = DirectX 2.0 installed
  3200. // 0x00030000 = DirectX 3.0 installed
  3201. // 0x00030001 = DirectX 3.0a installed
  3202. // 0x00050000 = DirectX 5.0 installed
  3203. // 0x00060000 = DirectX 6.0 installed
  3204. // 0x00060100 = DirectX 6.1 installed
  3205. // 0x00060101 = DirectX 6.1a installed
  3206. // 0x00070000 = DirectX 7.0 installed
  3207. // 0x00070001 = DirectX 7.0a installed
  3208. // 0x00080000 = DirectX 8.0 installed
  3209. // 0x00080100 = DirectX 8.1 installed
  3210. // 0x00080101 = DirectX 8.1a installed
  3211. // 0x00080102 = DirectX 8.1b installed
  3212. // 0x00080200 = DirectX 8.2 installed
  3213. // 0x00090000 = DirectX 9.0 installed
  3214. // 0x00090001 = DirectX 9.0a installed
  3215. // 0x00090002 = DirectX 9.0b installed
  3216. // strDirectXVersion - Destination string to receive a string name of the DirectX Version. Can be NULL.
  3217. // cchDirectXVersion - Size of destination buffer in characters. Length should be at least 10 chars.
  3218. // Returns: S_OK if the function succeeds.
  3219. // E_FAIL if the DirectX version info couldn't be determined.
  3220. //
  3221. // Please note that this code is intended as a general guideline. Your
  3222. // app will probably be able to simply query for functionality (via
  3223. // QueryInterface) for one or two components.
  3224. //
  3225. // Also please ensure your app will run on future releases of DirectX.
  3226. // For example:
  3227. // "if( dwDirectXVersion != 0x00080100 ) return false;" is VERY BAD.
  3228. // "if( dwDirectXVersion < 0x00080100 ) return false;" is MUCH BETTER.
  3229. //-----------------------------------------------------------------------------
  3230. function GetDXVersion(var pdwDirectXVersion : DWORD; out strDirectXVersion : String) : HResult;
  3231. function GetDirectXVersionViaDxDiag(var pdwDirectXVersionMajor : dword;
  3232. var pdwDirectXVersionMinor : dword;
  3233. var pcDirectXVersionLetter : char) : HResult;
  3234. {$IFDEF VER130}
  3235. function FindVarData(const V: Variant): PVarData;
  3236. begin
  3237. Result := @TVarData(V);
  3238. while Result.VType = varByRef or varVariant do
  3239. Result := PVarData(Result.VPointer);
  3240. end;
  3241. function VarIsType(const V: Variant; AVarType: TVarType): Boolean;
  3242. begin
  3243. Result := FindVarData(V)^.VType = AVarType;
  3244. end;
  3245. {$ENDIF}
  3246. var
  3247. hr : HRESULT;
  3248. bCleanupCOM : Boolean;
  3249. bSuccessGettingMajor : Boolean;
  3250. bSuccessGettingMinor : Boolean;
  3251. bSuccessGettingLetter : Boolean;
  3252. bGotDirectXVersion : Boolean;
  3253. pDxDiagProvider : IDxDiagProvider;
  3254. dxDiagInitParam : TDXDIAGINITPARAMS;
  3255. pDxDiagRoot : IDxDiagContainer;
  3256. pDxDiagSystemInfo : IDxDiagContainer;
  3257. va : OleVariant;
  3258. strDestination : String;
  3259. Begin
  3260. bSuccessGettingMajor := false;
  3261. bSuccessGettingMinor := false;
  3262. bSuccessGettingLetter := false;
  3263. // Init COM. COM may fail if its already been inited with a different
  3264. // concurrency model. And if it fails you shouldn't release it.
  3265. hr := CoInitialize(nil);
  3266. bCleanupCOM := SUCCEEDED(hr);
  3267. // Get an IDxDiagProvider
  3268. bGotDirectXVersion := false;
  3269. pDxDiagProvider := Nil;
  3270. hr := CoCreateInstance(CLSID_DxDiagProvider, Nil, CLSCTX_INPROC_SERVER, IID_IDxDiagProvider, pDxDiagProvider);
  3271. if SUCCEEDED(hr) then
  3272. Begin
  3273. // Fill out a DXDIAG_INIT_PARAMS struct
  3274. dxDiagInitParam.dwSize := sizeof(TDXDIAGINITPARAMS);
  3275. dxDiagInitParam.dwDxDiagHeaderVersion := DXDIAG_DX9_SDK_VERSION;
  3276. dxDiagInitParam.bAllowWHQLChecks := false;
  3277. dxDiagInitParam.pReserved := Nil;
  3278. // Init the m_pDxDiagProvider
  3279. hr := pDxDiagProvider.Initialize(@dxDiagInitParam);
  3280. if SUCCEEDED(hr) then
  3281. Begin
  3282. pDxDiagRoot := Nil;
  3283. pDxDiagSystemInfo := Nil;
  3284. // Get the DxDiag root container
  3285. hr := pDxDiagProvider.GetRootContainer(pDxDiagRoot);
  3286. if SUCCEEDED(hr) then
  3287. Begin
  3288. // Get the object called DxDiag_SystemInfo
  3289. hr := pDxDiagRoot.GetChildContainer('DxDiag_SystemInfo', pDxDiagSystemInfo);
  3290. if SUCCEEDED(hr) then
  3291. Begin
  3292. // Get the "dwDirectXVersionMajor" property
  3293. VariantInit(Va);
  3294. hr := pDxDiagSystemInfo.GetProp('dwDirectXVersionMajor', va);
  3295. if (SUCCEEDED(hr)) and (VarIsType(va, VT_UI4)) then
  3296. Begin
  3297. pdwDirectXVersionMajor := Va;
  3298. bSuccessGettingMajor := true;
  3299. End;
  3300. VariantClear(va);
  3301. // Get the "dwDirectXVersionMinor" property
  3302. hr := pDxDiagSystemInfo.GetProp('dwDirectXVersionMinor', va);
  3303. if (SUCCEEDED(hr)) and (VarIsType(va ,VT_UI4)) then
  3304. Begin
  3305. pdwDirectXVersionMinor := va;
  3306. bSuccessGettingMinor := true;
  3307. End;
  3308. VariantClear(va);
  3309. // Get the "szDirectXVersionLetter" property
  3310. hr := pDxDiagSystemInfo.GetProp('szDirectXVersionLetter', va);
  3311. If (SUCCEEDED(hr)) and (VarIsType(va , VT_BSTR)) then
  3312. Begin
  3313. strDestination := WideCharToString(TVarData(va).VOleStr);
  3314. pcDirectXVersionLetter := StrDestination[1];
  3315. bSuccessGettingLetter := true;
  3316. End;
  3317. VariantClear(va);
  3318. // If it all worked right, then mark it down
  3319. bGotDirectXVersion := bSuccessGettingMajor and bSuccessGettingMinor and bSuccessGettingLetter;
  3320. pDxDiagSystemInfo := Nil;
  3321. end;
  3322. pDxDiagRoot := Nil;
  3323. End;
  3324. end;
  3325. pDxDiagProvider := Nil;
  3326. end;
  3327. if bCleanupCOM then
  3328. CoUninitialize;
  3329. if bGotDirectXVersion then
  3330. result := S_OK
  3331. else
  3332. result := E_FAIL;
  3333. end;
  3334. //-----------------------------------------------------------------------------
  3335. // Name: GetDirectXVerionViaFileVersions()
  3336. // Desc: Tries to get the DirectX version by looking at DirectX file versions
  3337. //-----------------------------------------------------------------------------
  3338. function GetDirectXVerionViaFileVersions(var pdwDirectXVersionMajor : DWORD;
  3339. var pdwDirectXVersionMinor : DWORD;
  3340. var pcDirectXVersionLetter : Char) : HResult;
  3341. type
  3342. TFileVersion = record
  3343. Major : integer;
  3344. Minor : integer;
  3345. Release : integer;
  3346. Build : integer;
  3347. End;
  3348. function CompareFileVersion(Version1, Version2 : TFileVersion) : Integer;
  3349. var
  3350. TmpStr1,
  3351. TmpStr2 : String;
  3352. Begin
  3353. TmpStr1 := Format('%4.4d%4.4d%8.8d%4.4d', [Version1.Major, Version1.Minor, Version1.Release, Version1.Build]);
  3354. TmpStr2 := Format('%4.4d%4.4d%8.8d%4.4d', [Version2.Major, Version2.Minor, Version2.Release, Version2.Build]);
  3355. // milenko start (delph 5 compatibility)
  3356. // Result := CompareValue(Strtoint64(TmpStr1),Strtoint64(TmpStr2));
  3357. Result := Strtoint64(TmpStr1) - Strtoint64(TmpStr2);
  3358. if Result > 0 then Result := 1
  3359. else if Result < 0 then Result := -1;
  3360. // milenko end
  3361. End;
  3362. function ReadVersionInfo(Filename: string) : TFileVersion;
  3363. var
  3364. Info : PVSFixedFileInfo;
  3365. {$ifdef VER120}
  3366. InfoSize : Cardinal;
  3367. {$else}
  3368. InfoSize : UINT;
  3369. {$endif}
  3370. nHwnd : DWORD;
  3371. BufferSize : DWORD;
  3372. Buffer : Pointer;
  3373. begin
  3374. ZeroMemory(@Result, Sizeof(TFileVersion));
  3375. If Not FileExists(Filename) then Exit;
  3376. BufferSize := GetFileVersionInfoSize(pchar(filename),nHWnd); // Get buffer size
  3377. if BufferSize <> 0 then // if zero, there is no version info
  3378. begin
  3379. GetMem( Buffer, BufferSize); // allocate buffer memory
  3380. try
  3381. if GetFileVersionInfo(PChar(filename),nHWnd,BufferSize,Buffer) then
  3382. begin
  3383. // got version info
  3384. if VerQueryValue(Buffer, '\', Pointer(Info), InfoSize) then
  3385. begin
  3386. // got root block version information
  3387. Result.Major := HiWord(Info^.dwFileVersionMS); // extract major version
  3388. Result.Minor := LoWord(Info^.dwFileVersionMS); // extract minor version
  3389. Result.Release := HiWord(Info^.dwFileVersionLS); // extract release version
  3390. Result.Build := LoWord(Info^.dwFileVersionLS); // extract build version
  3391. end;
  3392. end;
  3393. finally
  3394. FreeMem(Buffer, BufferSize); // release buffer memory
  3395. end;
  3396. end;
  3397. end;
  3398. function FileVersion(Major, Minor, Release, Build : integer) : TFileVersion;
  3399. Begin
  3400. Result.Major := Major;
  3401. Result.Minor := Minor;
  3402. Result.Release := Release;
  3403. Result.Build := Build;
  3404. End;
  3405. var
  3406. szPath : PChar;
  3407. Path : String;
  3408. ddraw_Version,
  3409. d3drg8x_Version,
  3410. dplayx_Version,
  3411. dinput_Version,
  3412. d3d8_Version,
  3413. mpg2splt_Version,
  3414. dpnet_Version,
  3415. d3d9_Version : TFileVersion;
  3416. begin
  3417. pdwDirectXVersionMajor := 0;
  3418. pdwDirectXVersionMinor := 0;
  3419. pcDirectXVersionLetter := ' ';
  3420. Result := E_Fail;
  3421. szPath := GetMemory(MAX_PATH);
  3422. If GetSystemDirectory(szPath, MAX_PATH) = 0 then
  3423. Begin
  3424. FreeMemory(szPath);
  3425. Exit;
  3426. End;
  3427. Path := StrPas(szPath);
  3428. FreeMemory(szPath);
  3429. If Path[length(Path)] <> '\' then
  3430. Path := Path + '\';
  3431. ddraw_Version := ReadVersionInfo(Path+'ddraw.dll');
  3432. d3drg8x_Version := ReadVersionInfo(Path+'d3drg8x.dll');
  3433. dplayx_Version := ReadVersionInfo(Path+'dplayx.dll');
  3434. dinput_Version := ReadVersionInfo(Path+'dinput.dll');
  3435. d3d8_Version := ReadVersionInfo(Path+'d3d8.dll');
  3436. mpg2splt_Version := ReadVersionInfo(Path+'mpg2splt.ax');
  3437. dpnet_Version := ReadVersionInfo(Path+'dpnet.dll');
  3438. d3d9_Version := ReadVersionInfo(Path+'d3d9.dll');
  3439. If CompareFileVersion(ddraw_Version, FileVersion(4,2,0,95)) >= 0 then // Win9x version
  3440. Begin
  3441. // ddraw.dll is >= DX1.0 version, so we must be at least DX1.0
  3442. pdwDirectXVersionMajor := 1;
  3443. pdwDirectXVersionMinor := 0;
  3444. pcDirectXVersionLetter := ' ';
  3445. End;
  3446. If CompareFileVersion(ddraw_Version, FileVersion(4, 3, 0, 1096)) >= 0 then // Win9x version
  3447. Begin
  3448. // ddraw.dll is is >= DX2.0 version, so we must DX2.0 or DX2.0a (no redist change)
  3449. pdwDirectXVersionMajor := 2;
  3450. pdwDirectXVersionMinor := 0;
  3451. pcDirectXVersionLetter := ' ';
  3452. End;
  3453. If CompareFileVersion(ddraw_Version, FileVersion(4, 4, 0, 68)) >= 0 then // Win9x version
  3454. Begin
  3455. // ddraw.dll is >= DX3.0 version, so we must be at least DX3.0
  3456. pdwDirectXVersionMajor := 3;
  3457. pdwDirectXVersionMinor := 0;
  3458. pcDirectXVersionLetter := ' ';
  3459. End;
  3460. If CompareFileVersion(d3drg8x_Version, FileVersion(4, 4, 0, 70)) >= 0 then // Win9x version
  3461. Begin
  3462. // d3drg8x.dll is the DX3.0a version, so we must be DX3.0a or DX3.0b (no redist change)
  3463. pdwDirectXVersionMajor := 3;
  3464. pdwDirectXVersionMinor := 0;
  3465. pcDirectXVersionLetter := 'a';
  3466. End;
  3467. If CompareFileVersion(ddraw_Version, FileVersion(4, 5, 0, 155)) >= 0 then // Win9x version
  3468. Begin
  3469. // ddraw.dll is the DX5.0 version, so we must be DX5.0 or DX5.2 (no redist change)
  3470. pdwDirectXVersionMajor := 5;
  3471. pdwDirectXVersionMinor := 0;
  3472. pcDirectXVersionLetter := ' ';
  3473. End;
  3474. If CompareFileVersion(ddraw_Version, FileVersion(4, 6, 0, 318)) >= 0 then // Win9x version
  3475. Begin
  3476. // ddraw.dll is the DX6.0 version, so we must be at least DX6.0
  3477. pdwDirectXVersionMajor := 6;
  3478. pdwDirectXVersionMinor := 0;
  3479. pcDirectXVersionLetter := ' ';
  3480. End;
  3481. If CompareFileVersion(ddraw_Version, FileVersion(4, 6, 0, 436)) >= 0 then // Win9x version
  3482. Begin
  3483. // ddraw.dll is the DX6.1 version, so we must be at least DX6.1
  3484. pdwDirectXVersionMajor := 6;
  3485. pdwDirectXVersionMinor := 1;
  3486. pcDirectXVersionLetter := ' ';
  3487. End;
  3488. If CompareFileVersion(dplayx_Version, FileVersion(4, 6, 3, 518)) >= 0 then // Win9x version
  3489. Begin
  3490. // dplayx.dll is the DX6.1a version, so we must be at least DX6.1a
  3491. pdwDirectXVersionMajor := 6;
  3492. pdwDirectXVersionMinor := 1;
  3493. pcDirectXVersionLetter := 'a';
  3494. End;
  3495. If CompareFileVersion(ddraw_Version, FileVersion(4, 7, 0, 700)) >= 0 then // Win9x version
  3496. Begin
  3497. // TODO: find win2k version
  3498. // ddraw.dll is the DX7.0 version, so we must be at least DX7.0
  3499. pdwDirectXVersionMajor := 7;
  3500. pdwDirectXVersionMinor := 0;
  3501. pcDirectXVersionLetter := ' ';
  3502. End;
  3503. If CompareFileVersion(dinput_Version, FileVersion(4, 7, 0, 716)) >= 0 then // Win9x version
  3504. Begin
  3505. // TODO: find win2k version
  3506. // dinput.dll is the DX7.0a version, so we must be at least DX7.0a
  3507. pdwDirectXVersionMajor := 7;
  3508. pdwDirectXVersionMinor := 0;
  3509. pcDirectXVersionLetter := 'a';
  3510. End;
  3511. If ((ddraw_Version.Major = 4) and (CompareFileVersion(ddraw_Version, FileVersion(4, 8, 0, 400)) >= 0)) or // Win9x version
  3512. ((ddraw_Version.Major = 5) and (CompareFileVersion(ddraw_Version, FileVersion(5, 1, 2258, 400)) >= 0)) then // Win2k/WinXP version
  3513. Begin
  3514. // ddraw.dll is the DX8.0 version, so we must be at least DX8.0 or DX8.0a (no redist change)
  3515. //
  3516. // DirectX 8.0a contains updates for issues with international installs on Windows 2000 and issues where
  3517. // input devices could have buttons disabled that were enabled with previous DirectX releases.
  3518. // There are no other changes.
  3519. pdwDirectXVersionMajor := 8;
  3520. pdwDirectXVersionMinor := 0;
  3521. pcDirectXVersionLetter := ' ';
  3522. End;
  3523. If ((d3d8_Version.Major = 4) and (CompareFileVersion(d3d8_Version, FileVersion(4, 8, 1, 881)) >= 0)) or // Win9x version
  3524. ((d3d8_Version.Major = 5) and (CompareFileVersion(d3d8_Version, FileVersion(5, 1, 2600, 881)) >= 0)) then // Win2k/WinXP version
  3525. Begin
  3526. // d3d8.dll is the DX8.1 version, so we must be at least DX8.1
  3527. pdwDirectXVersionMajor := 8;
  3528. pdwDirectXVersionMinor := 1;
  3529. pcDirectXVersionLetter := ' ';
  3530. End;
  3531. If ((d3d8_Version.Major = 4) and (CompareFileVersion(d3d8_Version, FileVersion(4, 8, 1, 901)) >= 0)) or // Win9x version
  3532. ((d3d8_Version.Major = 5) and (CompareFileVersion(d3d8_Version, FileVersion(5, 1, 2600, 901)) >= 0)) then // Win2k/WinXP version
  3533. Begin
  3534. // d3d8.dll is the DX8.1 version, so we must be at least DX8.1
  3535. pdwDirectXVersionMajor := 8;
  3536. pdwDirectXVersionMinor := 1;
  3537. pcDirectXVersionLetter := 'a';
  3538. End;
  3539. If (CompareFileVersion(mpg2splt_Version, FileVersion(6, 3, 1, 885)) >= 0) then // Win9x/Win2k/WinXP version
  3540. Begin
  3541. // quartz.dll is the DX8.1b version, so we must be at least DX8.1b
  3542. pdwDirectXVersionMajor := 8;
  3543. pdwDirectXVersionMinor := 1;
  3544. pcDirectXVersionLetter := 'b';
  3545. End;
  3546. If ((dpnet_Version.Major = 4) and (CompareFileVersion(dpnet_Version, FileVersion(4, 9, 0, 134)) >= 0)) or // Win9x version
  3547. ((dpnet_Version.Major = 5) and (CompareFileVersion(dpnet_Version, FileVersion(5, 2, 3677, 134)) >= 0)) then // Win2k/WinXP version
  3548. Begin
  3549. // dpnet.dll is the DX8.2 version, so we must be at least DX8.2
  3550. pdwDirectXVersionMajor := 8;
  3551. pdwDirectXVersionMinor := 2;
  3552. pcDirectXVersionLetter := ' ';
  3553. End;
  3554. If ((d3d9_Version.Major = 4) and (CompareFileVersion(d3d9_Version, FileVersion(4, 9, 0, 900)) >= 0)) or // Win9x version
  3555. ((d3d9_Version.Major = 5) and (CompareFileVersion(d3d9_Version, FileVersion(5, 3, 0, 900)) >= 0)) then // Win2k/WinXP version
  3556. Begin
  3557. // d3d9.dll is the DX9.0 version, so we must be at least DX9.0
  3558. pdwDirectXVersionMajor := 9;
  3559. pdwDirectXVersionMinor := 0;
  3560. pcDirectXVersionLetter := ' ';
  3561. End;
  3562. If ((d3d9_Version.Major = 4) and (CompareFileVersion(d3d9_Version, FileVersion(4, 9, 0, 901)) >= 0)) or // Win9x version
  3563. ((d3d9_Version.Major = 5) and (CompareFileVersion(d3d9_Version, FileVersion(5, 3, 0, 901)) >= 0)) then // Win2k/WinXP version
  3564. Begin
  3565. // d3d9.dll is the DX9.0a version, so we must be at least DX9.0a
  3566. pdwDirectXVersionMajor := 9;
  3567. pdwDirectXVersionMinor := 0;
  3568. pcDirectXVersionLetter := 'a';
  3569. End;
  3570. If ((d3d9_Version.Major = 4) and (CompareFileVersion(d3d9_Version, FileVersion(4, 9, 0, 902)) >= 0)) or // Win9x version
  3571. ((d3d9_Version.Major = 5) and (CompareFileVersion(d3d9_Version, FileVersion(5, 3, 0, 902)) >= 0)) then // Win2k/WinXP version
  3572. Begin
  3573. // d3d9.dll is the DX9.0b version, so we must be at least DX9.0b
  3574. pdwDirectXVersionMajor := 9;
  3575. pdwDirectXVersionMinor := 0;
  3576. pcDirectXVersionLetter := 'b';
  3577. End;
  3578. Result := s_OK;
  3579. end;
  3580. var
  3581. dwDirectXVersionMajor : DWORD;
  3582. dwDirectXVersionMinor : DWORD;
  3583. cDirectXVersionLetter : CHAR;
  3584. dwDirectXVersion : DWORD;
  3585. Begin
  3586. // Init values to unknown
  3587. pdwDirectXVersion := 0;
  3588. strDirectXVersion := '';
  3589. dwDirectXVersionMajor := 0;
  3590. dwDirectXVersionMinor := 0;
  3591. cDirectXVersionLetter := ' ';
  3592. // First, try to use dxdiag's COM interface to get the DirectX version.
  3593. // The only downside is this will only work on DX9 or later.
  3594. Result := GetDirectXVersionViaDxDiag(dwDirectXVersionMajor, dwDirectXVersionMinor, cDirectXVersionLetter);
  3595. If Result = E_Fail then
  3596. // Getting the DirectX version info from DxDiag failed,
  3597. // so most likely we are on DX8.x or earlier
  3598. Result := GetDirectXVerionViaFileVersions(dwDirectXVersionMajor, dwDirectXVersionMinor, cDirectXVersionLetter);
  3599. // If both techniques failed, then return E_FAIL
  3600. If Result = E_Fail then
  3601. Exit;
  3602. // Set the output values to what we got and return
  3603. // like 0x00080102 which would represent DX8.1b
  3604. dwDirectXVersion := dwDirectXVersionMajor;
  3605. dwDirectXVersion := dwDirectXVersion shl 8;
  3606. dwDirectXVersion := dwDirectXVersion + dwDirectXVersionMinor;
  3607. dwDirectXVersion := dwDirectXVersion shl 8;
  3608. if (Ord(cDirectXVersionLetter) >= 97) and (Ord(cDirectXVersionLetter) <= 122) then
  3609. dwDirectXVersion := dwDirectXVersion + int64(Ord(cDirectXVersionLetter) - 96);
  3610. pdwDirectXVersion := dwDirectXVersion;
  3611. If dwDirectXVersion > 0 then
  3612. Begin
  3613. if cDirectXVersionLetter = ' ' then
  3614. strDirectXVersion := Format('%d.%d', [dwDirectXVersionMajor, dwDirectXVersionMinor])
  3615. else
  3616. strDirectXVersion := Format('%d.%d%s', [dwDirectXVersionMajor, dwDirectXVersionMinor, cDirectXVersionLetter]);
  3617. End;
  3618. Result := S_OK;
  3619. End;
  3620. // Michael End.
  3621. // milenko start DMO TMediaBuffer implementation
  3622. constructor TMediaBuffer.Create(MaxLen: DWORD);
  3623. begin
  3624. inherited Create;
  3625. FRefCount := 0;
  3626. FMaxLength := MaxLen;
  3627. FLength := 0;
  3628. FData := nil;
  3629. FData := AllocMem(MaxLen);
  3630. Assert(Assigned(FData));
  3631. end;
  3632. destructor TMediaBuffer.Destroy;
  3633. begin
  3634. if Assigned(FData) then
  3635. begin
  3636. FreeMem(FData);
  3637. FData := nil;
  3638. end;
  3639. end;
  3640. class function TMediaBuffer.CreateBuffer(MaxLen: DWORD; const IID: TGUID; out Obj): HRESULT;
  3641. var
  3642. pBuffer: TMediaBuffer;
  3643. begin
  3644. try
  3645. pBuffer := TMediaBuffer.Create(MaxLen);
  3646. Result := pBuffer.QueryInterface(IID, Obj);
  3647. except
  3648. Result := E_OUTOFMEMORY;
  3649. end;
  3650. end;
  3651. function TMediaBuffer.QueryInterface(const IID: TGUID; out Obj): HResult; stdcall;
  3652. begin
  3653. if not Assigned(@Obj) then
  3654. begin
  3655. Result := E_POINTER;
  3656. Exit;
  3657. end else
  3658. if IsEqualGUID(IID, IID_IMediaBuffer) or IsEqualGUID(IID, IUnknown) then
  3659. begin
  3660. if GetInterface(IID,Obj) then
  3661. begin
  3662. Result := S_OK;
  3663. Exit;
  3664. end
  3665. end;
  3666. Pointer(Obj) := nil;
  3667. Result := E_NOINTERFACE;
  3668. end;
  3669. function TMediaBuffer._AddRef: Integer; stdcall;
  3670. begin
  3671. Result := InterlockedIncrement(FRefCount);
  3672. end;
  3673. function TMediaBuffer._Release: Integer; stdcall;
  3674. begin
  3675. Result := InterlockedDecrement(FRefCount);
  3676. if (Result = 0) then Free;
  3677. end;
  3678. function TMediaBuffer.SetLength(cbLength: DWORD): HResult; stdcall;
  3679. begin
  3680. if (cbLength > FMaxLength) then
  3681. begin
  3682. Result := E_INVALIDARG;
  3683. end else
  3684. begin
  3685. FLength := cbLength;
  3686. Result := S_OK;
  3687. end;
  3688. end;
  3689. function TMediaBuffer.GetMaxLength(out pcbMaxLength: DWORD): HResult; stdcall;
  3690. begin
  3691. if not Assigned(@pcbMaxLength) then
  3692. begin
  3693. Result := E_POINTER;
  3694. Exit;
  3695. end else
  3696. begin
  3697. pcbMaxLength := FMaxLength;
  3698. Result := S_OK;
  3699. end;
  3700. end;
  3701. function TMediaBuffer.GetBufferAndLength(out ppBuffer: PByte; // not filled if NULL
  3702. out pcbLength: DWORD // not filled if NULL
  3703. ): HResult; stdcall;
  3704. begin
  3705. if not Assigned(@ppBuffer) or not Assigned(@pcbLength) then
  3706. begin
  3707. Result := E_POINTER;
  3708. Exit;
  3709. end;
  3710. ppBuffer := FData;
  3711. pcbLength := FLength;
  3712. Result := S_OK;
  3713. end;
  3714. // milenko end
  3715. // milenko start wxutil implementation
  3716. function EnlargedUnsignedDivide(Dividend: ULARGE_INTEGER; Divisor: ULONG; Remainder: PULONG): ULONG; stdcall;
  3717. asm
  3718. mov eax, Dividend.LowPart
  3719. mov edx, Dividend.HighPart
  3720. mov ecx, Remainder
  3721. div Divisor
  3722. or ecx,ecx
  3723. jz @@End
  3724. mov [ecx],edx
  3725. @@End:
  3726. end;
  3727. function Int32x32To64(a, b: integer): Int64;
  3728. asm
  3729. imul b
  3730. end;
  3731. function MILLISECONDS_TO_100NS_UNITS(Ms: LONGLONG): LONGLONG;
  3732. begin
  3733. Result := Int32x32To64((Ms), (UNITS div MILLISECONDS))
  3734. end;
  3735. function UInt32x32To64(a, b: DWORD): ULONGLONG;
  3736. asm
  3737. mul b
  3738. end;
  3739. function llMulDiv(a, b, c, d: LONGLONG): LONGLONG;
  3740. var
  3741. ua, ub : ULARGE_INTEGER;
  3742. uc : DWORDLONG;
  3743. bSign : BOOL;
  3744. p, ud : array[0..1] of ULARGE_INTEGER;
  3745. x : ULARGE_INTEGER;
  3746. uliTotal : ULARGE_INTEGER;
  3747. ullResult : DWORDLONG;
  3748. ulic : ULARGE_INTEGER;
  3749. uliDividend : ULARGE_INTEGER;
  3750. uliResult : ULARGE_INTEGER;
  3751. dwDivisor : DWORD;
  3752. i : integer;
  3753. begin
  3754. if a >= 0 then ua.QuadPart := DWORDLONG(a)
  3755. else ua.QuadPart := DWORDLONG(-a);
  3756. if b >= 0 then ub.QuadPart := DWORDLONG(b)
  3757. else ua.QuadPart := DWORDLONG(-b);
  3758. if c >= 0 then uc := DWORDLONG(c)
  3759. else uc := DWORDLONG(-c);
  3760. bSign := (a < 0) xor (b < 0);
  3761. p[0].QuadPart := UInt32x32To64(ua.LowPart, ub.LowPart);
  3762. x.QuadPart := UInt32x32To64(ua.LowPart, ub.HighPart) +
  3763. UInt32x32To64(ua.HighPart, ub.LowPart) +
  3764. p[0].HighPart;
  3765. p[0].HighPart := x.LowPart;
  3766. p[1].QuadPart := UInt32x32To64(ua.HighPart, ub.HighPart) + x.HighPart;
  3767. if (d <> 0) then
  3768. begin
  3769. if (bSign) then
  3770. begin
  3771. ud[0].QuadPart := DWORDLONG(-d);
  3772. if (d > 0) then ud[1].QuadPart := DWORDLONG(LONGLONG(-1))
  3773. else ud[1].QuadPart := DWORDLONG(0);
  3774. end else
  3775. begin
  3776. ud[0].QuadPart := DWORDLONG(d);
  3777. if (d < 0) then ud[1].QuadPart := DWORDLONG(LONGLONG(-1))
  3778. else ud[1].QuadPart := DWORDLONG(0);
  3779. end;
  3780. uliTotal.QuadPart := DWORDLONG(ud[0].LowPart) + p[0].LowPart;
  3781. p[0].LowPart := uliTotal.LowPart;
  3782. uliTotal.LowPart := uliTotal.HighPart;
  3783. uliTotal.HighPart := 0;
  3784. uliTotal.QuadPart := uliTotal.QuadPart + (DWORDLONG(ud[0].HighPart) + p[0].HighPart);
  3785. p[0].HighPart := uliTotal.LowPart;
  3786. uliTotal.LowPart := uliTotal.HighPart;
  3787. uliTotal.HighPart := 0;
  3788. p[1].QuadPart := p[1].QuadPart + ud[1].QuadPart + uliTotal.QuadPart;
  3789. if (LongInt(p[1].HighPart) < 0) then
  3790. begin
  3791. bSign := not bSign;
  3792. p[0].QuadPart := not p[0].QuadPart;
  3793. p[1].QuadPart := not p[1].QuadPart;
  3794. p[0].QuadPart := p[0].QuadPart + 1;
  3795. p[1].QuadPart := p[1].QuadPart + LongInt(p[0].QuadPart = 0);
  3796. end;
  3797. end;
  3798. if (c < 0) then bSign := not bSign;
  3799. if (uc <= p[1].QuadPart) then
  3800. begin
  3801. if bSign then Result := LONGLONG($8000000000000000)
  3802. else Result := LONGLONG($7FFFFFFFFFFFFFFF);
  3803. Exit;
  3804. end;
  3805. if (p[1].QuadPart = 0) then
  3806. begin
  3807. ullResult := p[0].QuadPart div uc;
  3808. if bSign then Result := -LONGLONG(ullResult)
  3809. else Result := LONGLONG(ullResult);
  3810. Exit;
  3811. end;
  3812. ulic.QuadPart := uc;
  3813. if (ulic.HighPart = 0) then
  3814. begin
  3815. dwDivisor := DWORD(uc);
  3816. uliDividend.HighPart := p[1].LowPart;
  3817. uliDividend.LowPart := p[0].HighPart;
  3818. if (uliDividend.QuadPart >= DWORDLONG(dwDivisor))
  3819. then uliResult.HighPart := EnlargedUnsignedDivide(uliDividend,dwDivisor,@p[0].HighPart)
  3820. else uliResult.HighPart := 0;
  3821. uliResult.LowPart := EnlargedUnsignedDivide(p[0],dwDivisor,nil);
  3822. if bSign then Result := -LONGLONG(uliResult.QuadPart)
  3823. else Result := LONGLONG(uliResult.QuadPart);
  3824. Exit;
  3825. end;
  3826. ullResult := 0;
  3827. for i := 0 to 63 do
  3828. begin
  3829. ullResult := ullResult shl 1;
  3830. p[1].QuadPart := p[1].QuadPart shl 1;
  3831. if ((p[0].HighPart and $80000000) <> 0) then p[1].LowPart := p[1].LowPart + 1;
  3832. p[0].QuadPart := p[0].QuadPart shl 1;
  3833. if (uc <= p[1].QuadPart) then
  3834. begin
  3835. p[1].QuadPart := p[1].QuadPart - uc;
  3836. ullResult := ullResult + 1;
  3837. end;
  3838. end;
  3839. if bSign then Result := -LONGLONG(ullResult)
  3840. else Result := LONGLONG(ullResult);
  3841. end;
  3842. function Int64x32Div32(a: LONGLONG; b, c, d: LongInt): LONGLONG;
  3843. var
  3844. ua : ULARGE_INTEGER;
  3845. ub : DWORD;
  3846. uc : DWORD;
  3847. bSign : BOOL;
  3848. p0 : ULARGE_INTEGER;
  3849. p1 : DWORD;
  3850. x : ULARGE_INTEGER;
  3851. ud0 : ULARGE_INTEGER;
  3852. ud1 : DWORD;
  3853. uliTotal : ULARGE_INTEGER;
  3854. uliDividend : ULARGE_INTEGER;
  3855. uliResult : ULARGE_INTEGER;
  3856. dwDivisor : DWORD;
  3857. begin
  3858. if a >= 0 then ua.QuadPart := DWORDLONG(a)
  3859. else ua.QuadPart := DWORDLONG(-a);
  3860. if b >= 0 then ub := DWORD(b)
  3861. else ub := DWORD(-b);
  3862. if c >= 0 then uc := DWORD(c)
  3863. else uc := DWORD(-c);
  3864. bSign := (a < 0) xor (b < 0);
  3865. p0.QuadPart := UInt32x32To64(ua.LowPart, ub);
  3866. if (ua.HighPart <> 0) then
  3867. begin
  3868. x.QuadPart := UInt32x32To64(ua.HighPart, ub) + p0.HighPart;
  3869. p0.HighPart := x.LowPart;
  3870. p1 := x.HighPart;
  3871. end else
  3872. begin
  3873. p1 := 0;
  3874. end;
  3875. if (d <> 0) then
  3876. begin
  3877. if bSign then
  3878. begin
  3879. ud0.QuadPart := DWORDLONG(-(LONGLONG(d)));
  3880. if (d > 0) then ud1 := DWORD(-1)
  3881. else ud1 := DWORD(0);
  3882. end else
  3883. begin
  3884. ud0.QuadPart := DWORDLONG(d);
  3885. if (d < 0) then ud1 := DWORD(-1)
  3886. else ud1 := DWORD(0);
  3887. end;
  3888. uliTotal.QuadPart := DWORDLONG(ud0.LowPart) + p0.LowPart;
  3889. p0.LowPart := uliTotal.LowPart;
  3890. uliTotal.LowPart := uliTotal.HighPart;
  3891. uliTotal.HighPart := 0;
  3892. uliTotal.QuadPart := uliTotal.QuadPart + (DWORDLONG(ud0.HighPart) + p0.HighPart);
  3893. p0.HighPart := uliTotal.LowPart;
  3894. p1 := p1 + ud1 + uliTotal.HighPart;
  3895. if (LongInt(p1) < 0) then
  3896. begin
  3897. bSign := not bSign;
  3898. p0.QuadPart := not p0.QuadPart;
  3899. p1 := not p1;
  3900. p0.QuadPart := p0.QuadPart + 1;
  3901. p1 := p1 + DWORD(p0.QuadPart = 0);
  3902. end;
  3903. end;
  3904. dwDivisor := uc;
  3905. if (c < 0) then bSign := not bSign;
  3906. if (uc <= p1) then
  3907. begin
  3908. if bSign then Result := LONGLONG($8000000000000000)
  3909. else Result := LONGLONG($7FFFFFFFFFFFFFFF);
  3910. Exit;
  3911. end;
  3912. uliDividend.HighPart := p1;
  3913. uliDividend.LowPart := p0.HighPart;
  3914. if (uliDividend.QuadPart >= DWORDLONG(dwDivisor)) then
  3915. begin
  3916. uliResult.HighPart := EnlargedUnsignedDivide(uliDividend, dwDivisor, @p0.HighPart);
  3917. end else
  3918. begin
  3919. uliResult.HighPart := 0;
  3920. end;
  3921. uliResult.LowPart := EnlargedUnsignedDivide(p0, dwDivisor, nil);
  3922. if bSign then Result := -LONGLONG(uliResult.QuadPart)
  3923. else Result := LONGLONG(uliResult.QuadPart);
  3924. end;
  3925. function HRESULT_FROM_WIN32(x: DWORD): HRESULT;
  3926. begin
  3927. if HRESULT(x) <= 0 then
  3928. Result := HRESULT(x)
  3929. else
  3930. Result := HRESULT((x and $0000FFFF) or (FACILITY_WIN32 shl 16) or $80000000);
  3931. end;
  3932. function AmGetLastErrorToHResult: HRESULT;
  3933. var
  3934. LastError: DWORD;
  3935. begin
  3936. LastError := GetLastError;
  3937. if(LastError <> 0) then Result := HRESULT_FROM_WIN32(LastError)
  3938. else Result := E_FAIL;
  3939. end;
  3940. function IsEqualObject(pFirst, pSecond: IUnknown): Boolean;
  3941. var
  3942. pUnknown1, // Retrieve the IUnknown interface
  3943. pUnknown2: IUnknown; // Retrieve the other IUnknown interface
  3944. begin
  3945. // Different objects can't have the same interface pointer for
  3946. // any interface
  3947. if (pFirst = pSecond) then
  3948. begin
  3949. Result := True;
  3950. Exit;
  3951. end;
  3952. // OK - do it the hard way - check if they have the same
  3953. // IUnknown pointers - a single object can only have one of these
  3954. ASSERT(pFirst <> nil);
  3955. ASSERT(pSecond <> nil);
  3956. // See if the IUnknown pointers match
  3957. Result := Succeeded(pFirst.QueryInterface(IUnknown,pUnknown1));
  3958. if (Result) then
  3959. begin
  3960. end;
  3961. ASSERT(Result);
  3962. ASSERT(pUnknown1 <> nil);
  3963. Result := Succeeded(pSecond.QueryInterface(IUnknown,pUnknown2));
  3964. // get rid of Delphi compiler warnings ..
  3965. if (Result) then
  3966. begin
  3967. end;
  3968. ASSERT(Result);
  3969. ASSERT(pUnknown2 <> nil);
  3970. // Release the extra interfaces we hold
  3971. Result := (pUnknown1 = pUnknown2);
  3972. pUnknown1 := nil;
  3973. pUnknown2 := nil;
  3974. end;
  3975. // milenko end
  3976. // milenko start namedguid implementation
  3977. function GetGUIDString(GUID: TGUID): String;
  3978. begin
  3979. if IsEqualGUID(GUID,MEDIASUBTYPE_AIFF) then Result := 'MEDIASUBTYPE_AIFF'
  3980. else if IsEqualGUID(GUID,MEDIASUBTYPE_AU) then Result := 'MEDIASUBTYPE_AU'
  3981. else if IsEqualGuid(GUID,MEDIASUBTYPE_AnalogVideo_NTSC_M) then Result := 'MEDIASUBTYPE_AnalogVideo_NTSC_M'
  3982. else if IsEqualGuid(GUID,MEDIASUBTYPE_AnalogVideo_PAL_B) then Result := 'MEDIASUBTYPE_AnalogVideo_PAL_B'
  3983. else if IsEqualGuid(GUID,MEDIASUBTYPE_AnalogVideo_PAL_D) then Result := 'MEDIASUBTYPE_AnalogVideo_PAL_D'
  3984. else if IsEqualGuid(GUID,MEDIASUBTYPE_AnalogVideo_PAL_G) then Result := 'MEDIASUBTYPE_AnalogVideo_PAL_G'
  3985. else if IsEqualGuid(GUID,MEDIASUBTYPE_AnalogVideo_PAL_H) then Result := 'MEDIASUBTYPE_AnalogVideo_PAL_H'
  3986. else if IsEqualGuid(GUID,MEDIASUBTYPE_AnalogVideo_PAL_I) then Result := 'MEDIASUBTYPE_AnalogVideo_PAL_I'
  3987. else if IsEqualGuid(GUID,MEDIASUBTYPE_AnalogVideo_PAL_M) then Result := 'MEDIASUBTYPE_AnalogVideo_PAL_M'
  3988. else if IsEqualGuid(GUID,MEDIASUBTYPE_AnalogVideo_PAL_N) then Result := 'MEDIASUBTYPE_AnalogVideo_PAL_N'
  3989. else if IsEqualGuid(GUID,MEDIASUBTYPE_AnalogVideo_SECAM_B) then Result := 'MEDIASUBTYPE_AnalogVideo_SECAM_B'
  3990. else if IsEqualGuid(GUID,MEDIASUBTYPE_AnalogVideo_SECAM_D) then Result := 'MEDIASUBTYPE_AnalogVideo_SECAM_D'
  3991. else if IsEqualGuid(GUID,MEDIASUBTYPE_AnalogVideo_SECAM_G) then Result := 'MEDIASUBTYPE_AnalogVideo_SECAM_G'
  3992. else if IsEqualGuid(GUID,MEDIASUBTYPE_AnalogVideo_SECAM_H) then Result := 'MEDIASUBTYPE_AnalogVideo_SECAM_H'
  3993. else if IsEqualGuid(GUID,MEDIASUBTYPE_AnalogVideo_SECAM_K) then Result := 'MEDIASUBTYPE_AnalogVideo_SECAM_K'
  3994. else if IsEqualGuid(GUID,MEDIASUBTYPE_AnalogVideo_SECAM_K1) then Result := 'MEDIASUBTYPE_AnalogVideo_SECAM_K1'
  3995. else if IsEqualGuid(GUID,MEDIASUBTYPE_AnalogVideo_SECAM_L) then Result := 'MEDIASUBTYPE_AnalogVideo_SECAM_L'
  3996. else if IsEqualGuid(GUID,MEDIASUBTYPE_ARGB1555) then Result := 'MEDIASUBTYPE_ARGB1555'
  3997. else if IsEqualGuid(GUID,MEDIASUBTYPE_ARGB4444) then Result := 'MEDIASUBTYPE_ARGB4444'
  3998. else if IsEqualGuid(GUID,MEDIASUBTYPE_ARGB32) then Result := 'MEDIASUBTYPE_ARGB32'
  3999. else if IsEqualGuid(GUID,MEDIASUBTYPE_A2R10G10B10) then Result := 'MEDIASUBTYPE_A2R10G10B10'
  4000. else if IsEqualGuid(GUID,MEDIASUBTYPE_A2B10G10R10) then Result := 'MEDIASUBTYPE_A2B10G10R10'
  4001. else if IsEqualGuid(GUID,MEDIASUBTYPE_AYUV) then Result := 'MEDIASUBTYPE_AYUV'
  4002. else if IsEqualGuid(GUID,MEDIASUBTYPE_AI44) then Result := 'MEDIASUBTYPE_AI44'
  4003. else if IsEqualGuid(GUID,MEDIASUBTYPE_IA44) then Result := 'MEDIASUBTYPE_IA44'
  4004. else if IsEqualGuid(GUID,MEDIASUBTYPE_NV12) then Result := 'MEDIASUBTYPE_NV12'
  4005. else if IsEqualGuid(GUID,MEDIASUBTYPE_IMC1) then Result := 'MEDIASUBTYPE_IMC1'
  4006. else if IsEqualGuid(GUID,MEDIASUBTYPE_IMC2) then Result := 'MEDIASUBTYPE_IMC2'
  4007. else if IsEqualGuid(GUID,MEDIASUBTYPE_IMC3) then Result := 'MEDIASUBTYPE_IMC3'
  4008. else if IsEqualGuid(GUID,MEDIASUBTYPE_IMC4) then Result := 'MEDIASUBTYPE_IMC4'
  4009. else if IsEqualGuid(GUID,MEDIASUBTYPE_Asf) then Result := 'MEDIASUBTYPE_Asf'
  4010. else if IsEqualGuid(GUID,MEDIASUBTYPE_Avi) then Result := 'MEDIASUBTYPE_Avi'
  4011. else if IsEqualGuid(GUID,MEDIASUBTYPE_CFCC) then Result := 'MEDIASUBTYPE_CFCC'
  4012. else if IsEqualGuid(GUID,MEDIASUBTYPE_CLJR) then Result := 'MEDIASUBTYPE_CLJR'
  4013. else if IsEqualGuid(GUID,MEDIASUBTYPE_CPLA) then Result := 'MEDIASUBTYPE_CPLA'
  4014. else if IsEqualGuid(GUID,MEDIASUBTYPE_CLPL) then Result := 'MEDIASUBTYPE_CLPL'
  4015. else if IsEqualGuid(GUID,MEDIASUBTYPE_DOLBY_AC3) then Result := 'MEDIASUBTYPE_DOLBY_AC3'
  4016. else if IsEqualGuid(GUID,MEDIASUBTYPE_DOLBY_AC3_SPDIF) then Result := 'MEDIASUBTYPE_DOLBY_AC3_SPDIF'
  4017. else if IsEqualGuid(GUID,MEDIASUBTYPE_DVCS) then Result := 'MEDIASUBTYPE_DVCS'
  4018. else if IsEqualGuid(GUID,MEDIASUBTYPE_DVD_LPCM_AUDIO) then Result := 'MEDIASUBTYPE_DVD_LPCM_AUDIO'
  4019. else if IsEqualGuid(GUID,MEDIASUBTYPE_DVD_NAVIGATION_DSI) then Result := 'MEDIASUBTYPE_DVD_NAVIGATION_DSI'
  4020. else if IsEqualGuid(GUID,MEDIASUBTYPE_DVD_NAVIGATION_PCI) then Result := 'MEDIASUBTYPE_DVD_NAVIGATION_PCI'
  4021. else if IsEqualGuid(GUID,MEDIASUBTYPE_DVD_NAVIGATION_PROVIDER) then Result := 'MEDIASUBTYPE_DVD_NAVIGATION_PROVIDER'
  4022. else if IsEqualGuid(GUID,MEDIASUBTYPE_DVD_SUBPICTURE) then Result := 'MEDIASUBTYPE_DVD_SUBPICTURE'
  4023. else if IsEqualGuid(GUID,MEDIASUBTYPE_DVSD) then Result := 'MEDIASUBTYPE_DVSD'
  4024. else if IsEqualGuid(GUID,MEDIASUBTYPE_DRM_Audio) then Result := 'MEDIASUBTYPE_DRM_Audio'
  4025. else if IsEqualGuid(GUID,MEDIASUBTYPE_DssAudio) then Result := 'MEDIASUBTYPE_DssAudio'
  4026. else if IsEqualGuid(GUID,MEDIASUBTYPE_DssVideo) then Result := 'MEDIASUBTYPE_DssVideo'
  4027. else if IsEqualGuid(GUID,MEDIASUBTYPE_IF09) then Result := 'MEDIASUBTYPE_IF09'
  4028. else if IsEqualGuid(GUID,MEDIASUBTYPE_IEEE_FLOAT) then Result := 'MEDIASUBTYPE_IEEE_FLOAT'
  4029. else if IsEqualGuid(GUID,MEDIASUBTYPE_IJPG) then Result := 'MEDIASUBTYPE_IJPG'
  4030. else if IsEqualGuid(GUID,MEDIASUBTYPE_IYUV) then Result := 'MEDIASUBTYPE_IYUV'
  4031. else if IsEqualGuid(GUID,MEDIASUBTYPE_Line21_BytePair) then Result := 'MEDIASUBTYPE_Line21_BytePair'
  4032. else if IsEqualGuid(GUID,MEDIASUBTYPE_Line21_GOPPacket) then Result := 'MEDIASUBTYPE_Line21_GOPPacket'
  4033. else if IsEqualGuid(GUID,MEDIASUBTYPE_Line21_VBIRawData) then Result := 'MEDIASUBTYPE_Line21_VBIRawData'
  4034. else if IsEqualGuid(GUID,MEDIASUBTYPE_MDVF) then Result := 'MEDIASUBTYPE_MDVF'
  4035. else if IsEqualGuid(GUID,MEDIASUBTYPE_MJPG) then Result := 'MEDIASUBTYPE_MJPG'
  4036. else if IsEqualGuid(GUID,MEDIASUBTYPE_MPEG1Audio) then Result := 'MEDIASUBTYPE_MPEG1Audio'
  4037. else if IsEqualGuid(GUID,MEDIASUBTYPE_MPEG1AudioPayload) then Result := 'MEDIASUBTYPE_MPEG1AudioPayload'
  4038. else if IsEqualGuid(GUID,MEDIASUBTYPE_MPEG1Packet) then Result := 'MEDIASUBTYPE_MPEG1Packet'
  4039. else if IsEqualGuid(GUID,MEDIASUBTYPE_MPEG1Payload) then Result := 'MEDIASUBTYPE_MPEG1Payload'
  4040. else if IsEqualGuid(GUID,MEDIASUBTYPE_MPEG1System) then Result := 'MEDIASUBTYPE_MPEG1System'
  4041. else if IsEqualGuid(GUID,MEDIASUBTYPE_MPEG1Video) then Result := 'MEDIASUBTYPE_MPEG1Video'
  4042. else if IsEqualGuid(GUID,MEDIASUBTYPE_MPEG1VideoCD) then Result := 'MEDIASUBTYPE_MPEG1VideoCD'
  4043. else if IsEqualGuid(GUID,MEDIASUBTYPE_MPEG2_AUDIO) then Result := 'MEDIASUBTYPE_MPEG2_AUDIO'
  4044. else if IsEqualGuid(GUID,MEDIASUBTYPE_MPEG2_PROGRAM) then Result := 'MEDIASUBTYPE_MPEG2_PROGRAM'
  4045. else if IsEqualGuid(GUID,MEDIASUBTYPE_MPEG2_TRANSPORT) then Result := 'MEDIASUBTYPE_MPEG2_TRANSPORT'
  4046. else if IsEqualGuid(GUID,MEDIASUBTYPE_MPEG2_VIDEO) then Result := 'MEDIASUBTYPE_MPEG2_VIDEO'
  4047. else if IsEqualGuid(GUID,MEDIASUBTYPE_None) then Result := 'MEDIASUBTYPE_None'
  4048. else if IsEqualGuid(GUID,MEDIASUBTYPE_Overlay) then Result := 'MEDIASUBTYPE_Overlay'
  4049. else if IsEqualGuid(GUID,MEDIASUBTYPE_PCM) then Result := 'MEDIASUBTYPE_PCM'
  4050. else if IsEqualGuid(GUID,MEDIASUBTYPE_PCMAudio_Obsolete) then Result := 'MEDIASUBTYPE_PCMAudio_Obsolete'
  4051. else if IsEqualGuid(GUID,MEDIASUBTYPE_Plum) then Result := 'MEDIASUBTYPE_Plum'
  4052. else if IsEqualGuid(GUID,MEDIASUBTYPE_QTJpeg) then Result := 'MEDIASUBTYPE_QTJpeg'
  4053. else if IsEqualGuid(GUID,MEDIASUBTYPE_QTMovie) then Result := 'MEDIASUBTYPE_QTMovie'
  4054. else if IsEqualGuid(GUID,MEDIASUBTYPE_QTRle) then Result := 'MEDIASUBTYPE_QTRle'
  4055. else if IsEqualGuid(GUID,MEDIASUBTYPE_QTRpza) then Result := 'MEDIASUBTYPE_QTRpza'
  4056. else if IsEqualGuid(GUID,MEDIASUBTYPE_QTSmc) then Result := 'MEDIASUBTYPE_QTSmc'
  4057. else if IsEqualGuid(GUID,MEDIASUBTYPE_RAW_SPORT) then Result := 'MEDIASUBTYPE_RAW_SPORT'
  4058. else if IsEqualGuid(GUID,MEDIASUBTYPE_RGB1) then Result := 'MEDIASUBTYPE_RGB1'
  4059. else if IsEqualGuid(GUID,MEDIASUBTYPE_RGB24) then Result := 'MEDIASUBTYPE_RGB24'
  4060. else if IsEqualGuid(GUID,MEDIASUBTYPE_RGB32) then Result := 'MEDIASUBTYPE_RGB32'
  4061. else if IsEqualGuid(GUID,MEDIASUBTYPE_RGB4) then Result := 'MEDIASUBTYPE_RGB4'
  4062. else if IsEqualGuid(GUID,MEDIASUBTYPE_RGB555) then Result := 'MEDIASUBTYPE_RGB555'
  4063. else if IsEqualGuid(GUID,MEDIASUBTYPE_RGB565) then Result := 'MEDIASUBTYPE_RGB565'
  4064. else if IsEqualGuid(GUID,MEDIASUBTYPE_RGB8) then Result := 'MEDIASUBTYPE_RGB8'
  4065. else if IsEqualGuid(GUID,MEDIASUBTYPE_SPDIF_TAG_241h) then Result := 'MEDIASUBTYPE_SPDIF_TAG_241h'
  4066. else if IsEqualGuid(GUID,MEDIASUBTYPE_TELETEXT) then Result := 'MEDIASUBTYPE_TELETEXT'
  4067. else if IsEqualGuid(GUID,MEDIASUBTYPE_TVMJ) then Result := 'MEDIASUBTYPE_TVMJ'
  4068. else if IsEqualGuid(GUID,MEDIASUBTYPE_UYVY) then Result := 'MEDIASUBTYPE_UYVY'
  4069. else if IsEqualGuid(GUID,MEDIASUBTYPE_VPVBI) then Result := 'MEDIASUBTYPE_VPVBI'
  4070. else if IsEqualGuid(GUID,MEDIASUBTYPE_VPVideo) then Result := 'MEDIASUBTYPE_VPVideo'
  4071. else if IsEqualGuid(GUID,MEDIASUBTYPE_WAKE) then Result := 'MEDIASUBTYPE_WAKE'
  4072. else if IsEqualGuid(GUID,MEDIASUBTYPE_WAVE) then Result := 'MEDIASUBTYPE_WAVE'
  4073. else if IsEqualGuid(GUID,MEDIASUBTYPE_Y211) then Result := 'MEDIASUBTYPE_Y211'
  4074. else if IsEqualGuid(GUID,MEDIASUBTYPE_Y411) then Result := 'MEDIASUBTYPE_Y411'
  4075. else if IsEqualGuid(GUID,MEDIASUBTYPE_Y41P) then Result := 'MEDIASUBTYPE_Y41P'
  4076. else if IsEqualGuid(GUID,MEDIASUBTYPE_YUY2) then Result := 'MEDIASUBTYPE_YUY2'
  4077. else if IsEqualGuid(GUID,MEDIASUBTYPE_YV12) then Result := 'MEDIASUBTYPE_YV12'
  4078. else if IsEqualGuid(GUID,MEDIASUBTYPE_YVU9) then Result := 'MEDIASUBTYPE_YVU9'
  4079. else if IsEqualGuid(GUID,MEDIASUBTYPE_YVYU) then Result := 'MEDIASUBTYPE_YVYU'
  4080. else if IsEqualGuid(GUID,MEDIASUBTYPE_YUYV) then Result := 'MEDIASUBTYPE_YUYV'
  4081. else if IsEqualGuid(GUID,MEDIASUBTYPE_dvhd) then Result := 'MEDIASUBTYPE_dvhd'
  4082. else if IsEqualGuid(GUID,MEDIASUBTYPE_dvsd) then Result := 'MEDIASUBTYPE_dvsd'
  4083. else if IsEqualGuid(GUID,MEDIASUBTYPE_dvsl) then Result := 'MEDIASUBTYPE_dvsl'
  4084. else if IsEqualGuid(GUID,MEDIATYPE_AUXLine21Data) then Result := 'MEDIATYPE_AUXLine21Data'
  4085. else if IsEqualGuid(GUID,MEDIATYPE_AnalogAudio) then Result := 'MEDIATYPE_AnalogAudio'
  4086. else if IsEqualGuid(GUID,MEDIATYPE_AnalogVideo) then Result := 'MEDIATYPE_AnalogVideo'
  4087. else if IsEqualGuid(GUID,MEDIATYPE_Audio) then Result := 'MEDIATYPE_Audio'
  4088. else if IsEqualGuid(GUID,MEDIATYPE_DVD_ENCRYPTED_PACK) then Result := 'MEDIATYPE_DVD_ENCRYPTED_PACK'
  4089. else if IsEqualGuid(GUID,MEDIATYPE_DVD_NAVIGATION) then Result := 'MEDIATYPE_DVD_NAVIGATION'
  4090. else if IsEqualGuid(GUID,MEDIATYPE_File) then Result := 'MEDIATYPE_File'
  4091. else if IsEqualGuid(GUID,MEDIATYPE_Interleaved) then Result := 'MEDIATYPE_Interleaved'
  4092. else if IsEqualGuid(GUID,MEDIATYPE_LMRT) then Result := 'MEDIATYPE_LMRT'
  4093. else if IsEqualGuid(GUID,MEDIATYPE_MPEG1SystemStream) then Result := 'MEDIATYPE_MPEG1SystemStream'
  4094. else if IsEqualGuid(GUID,MEDIATYPE_MPEG2_PES) then Result := 'MEDIATYPE_MPEG2_PES'
  4095. else if IsEqualGuid(GUID,MEDIATYPE_Midi) then Result := 'MEDIATYPE_Midi'
  4096. else if IsEqualGuid(GUID,MEDIATYPE_ScriptCommand) then Result := 'MEDIATYPE_ScriptCommand'
  4097. else if IsEqualGuid(GUID,MEDIATYPE_Stream) then Result := 'MEDIATYPE_Stream'
  4098. else if IsEqualGuid(GUID,MEDIATYPE_Text) then Result := 'MEDIATYPE_Text'
  4099. else if IsEqualGuid(GUID,MEDIATYPE_Timecode) then Result := 'MEDIATYPE_Timecode'
  4100. else if IsEqualGuid(GUID,MEDIATYPE_URL_STREAM) then Result := 'MEDIATYPE_URL_STREAM'
  4101. else if IsEqualGuid(GUID,MEDIATYPE_VBI) then Result := 'MEDIATYPE_VBI'
  4102. else if IsEqualGuid(GUID,MEDIATYPE_Video) then Result := 'MEDIATYPE_Video'
  4103. else if IsEqualGuid(GUID,WMMEDIATYPE_Audio) then Result := 'WMMEDIATYPE_Audio'
  4104. else if IsEqualGuid(GUID,WMMEDIATYPE_Video) then Result := 'WMMEDIATYPE_Video'
  4105. else if IsEqualGuid(GUID,WMMEDIATYPE_Script) then Result := 'WMMEDIATYPE_Script'
  4106. else if IsEqualGuid(GUID,WMMEDIATYPE_Image) then Result := 'WMMEDIATYPE_Image'
  4107. else if IsEqualGuid(GUID,WMMEDIATYPE_FileTransfer) then Result := 'WMMEDIATYPE_FileTransfer'
  4108. else if IsEqualGuid(GUID,WMMEDIATYPE_Text) then Result := 'WMMEDIATYPE_Text'
  4109. else if IsEqualGuid(GUID,WMMEDIASUBTYPE_Base) then Result := 'WMMEDIASUBTYPE_Base'
  4110. else if IsEqualGuid(GUID,WMMEDIASUBTYPE_RGB1) then Result := 'WMMEDIASUBTYPE_RGB1'
  4111. else if IsEqualGuid(GUID,WMMEDIASUBTYPE_RGB4) then Result := 'WMMEDIASUBTYPE_RGB4'
  4112. else if IsEqualGuid(GUID,WMMEDIASUBTYPE_RGB8) then Result := 'WMMEDIASUBTYPE_RGB8'
  4113. else if IsEqualGuid(GUID,WMMEDIASUBTYPE_RGB565) then Result := 'WMMEDIASUBTYPE_RGB565'
  4114. else if IsEqualGuid(GUID,WMMEDIASUBTYPE_RGB555) then Result := 'WMMEDIASUBTYPE_RGB555'
  4115. else if IsEqualGuid(GUID,WMMEDIASUBTYPE_RGB24) then Result := 'WMMEDIASUBTYPE_RGB24'
  4116. else if IsEqualGuid(GUID,WMMEDIASUBTYPE_RGB32) then Result := 'WMMEDIASUBTYPE_RGB32'
  4117. else if IsEqualGuid(GUID,WMMEDIASUBTYPE_I420) then Result := 'WMMEDIASUBTYPE_I420'
  4118. else if IsEqualGuid(GUID,WMMEDIASUBTYPE_IYUV) then Result := 'WMMEDIASUBTYPE_IYUV'
  4119. else if IsEqualGuid(GUID,WMMEDIASUBTYPE_YV12) then Result := 'WMMEDIASUBTYPE_YV12'
  4120. else if IsEqualGuid(GUID,WMMEDIASUBTYPE_YUY2) then Result := 'WMMEDIASUBTYPE_YUY2'
  4121. else if IsEqualGuid(GUID,WMMEDIASUBTYPE_UYVY) then Result := 'WMMEDIASUBTYPE_UYVY'
  4122. else if IsEqualGuid(GUID,WMMEDIASUBTYPE_YVYU) then Result := 'WMMEDIASUBTYPE_YVYU'
  4123. else if IsEqualGuid(GUID,WMMEDIASUBTYPE_YVU9) then Result := 'WMMEDIASUBTYPE_YVU9'
  4124. else if IsEqualGuid(GUID,WMMEDIASUBTYPE_MP43) then Result := 'WMMEDIASUBTYPE_MP43'
  4125. else if IsEqualGuid(GUID,WMMEDIASUBTYPE_MP4S) then Result := 'WMMEDIASUBTYPE_MP4S'
  4126. else if IsEqualGuid(GUID,WMMEDIASUBTYPE_WMV1) then Result := 'WMMEDIASUBTYPE_WMV1'
  4127. else if IsEqualGuid(GUID,WMMEDIASUBTYPE_WMV2) then Result := 'WMMEDIASUBTYPE_WMV2'
  4128. else if IsEqualGuid(GUID,WMMEDIASUBTYPE_WMV3) then Result := 'WMMEDIASUBTYPE_WMV3'
  4129. else if IsEqualGuid(GUID,WMMEDIASUBTYPE_MSS1) then Result := 'WMMEDIASUBTYPE_MSS1'
  4130. else if IsEqualGuid(GUID,WMMEDIASUBTYPE_MSS2) then Result := 'WMMEDIASUBTYPE_MSS2'
  4131. else if IsEqualGuid(GUID,WMMEDIASUBTYPE_MPEG2_VIDEO) then Result := 'WMMEDIASUBTYPE_MPEG2_VIDEO'
  4132. else if IsEqualGuid(GUID,WMMEDIASUBTYPE_PCM) then Result := 'WMMEDIASUBTYPE_PCM'
  4133. else if IsEqualGuid(GUID,WMMEDIASUBTYPE_DRM) then Result := 'WMMEDIASUBTYPE_DRM'
  4134. else if IsEqualGuid(GUID,WMMEDIASUBTYPE_WMAudioV9) then Result := 'WMMEDIASUBTYPE_WMAudioV9'
  4135. else if IsEqualGuid(GUID,WMMEDIASUBTYPE_WMAudio_Lossless) then Result := 'WMMEDIASUBTYPE_WMAudio_Lossless'
  4136. else if IsEqualGuid(GUID,WMMEDIASUBTYPE_WMAudioV8) then Result := 'WMMEDIASUBTYPE_WMAudioV8'
  4137. else if IsEqualGuid(GUID,WMMEDIASUBTYPE_WMAudioV7) then Result := 'WMMEDIASUBTYPE_WMAudioV7'
  4138. else if IsEqualGuid(GUID,WMMEDIASUBTYPE_WMAudioV2) then Result := 'WMMEDIASUBTYPE_WMAudioV2'
  4139. else if IsEqualGuid(GUID,WMMEDIASUBTYPE_ACELPnet) then Result := 'WMMEDIASUBTYPE_ACELPnet'
  4140. else if IsEqualGuid(GUID,WMMEDIASUBTYPE_WMSP1) then Result := 'WMMEDIASUBTYPE_WMSP1'
  4141. else if IsEqualGuid(GUID,WMFORMAT_VideoInfo) then Result := 'WMFORMAT_VideoInfo'
  4142. else if IsEqualGuid(GUID,WMFORMAT_WaveFormatEx) then Result := 'WMFORMAT_WaveFormatEx'
  4143. else if IsEqualGuid(GUID,WMFORMAT_Script) then Result := 'WMFORMAT_Script'
  4144. else if IsEqualGuid(GUID,WMFORMAT_MPEG2Video) then Result := 'WMFORMAT_MPEG2Video'
  4145. else if IsEqualGuid(GUID,WMSCRIPTTYPE_TwoStrings) then Result := 'WMSCRIPTTYPE_TwoStrings'
  4146. else if IsEqualGuid(GUID,PIN_CATEGORY_ANALOGVIDEOIN) then Result := 'PIN_CATEGORY_ANALOGVIDEOIN'
  4147. else if IsEqualGuid(GUID,PIN_CATEGORY_CAPTURE) then Result := 'PIN_CATEGORY_CAPTURE'
  4148. else if IsEqualGuid(GUID,PIN_CATEGORY_CC) then Result := 'PIN_CATEGORY_CC'
  4149. else if IsEqualGuid(GUID,PIN_CATEGORY_EDS) then Result := 'PIN_CATEGORY_EDS'
  4150. else if IsEqualGuid(GUID,PIN_CATEGORY_NABTS) then Result := 'PIN_CATEGORY_NABTS'
  4151. else if IsEqualGuid(GUID,PIN_CATEGORY_PREVIEW) then Result := 'PIN_CATEGORY_PREVIEW'
  4152. else if IsEqualGuid(GUID,PIN_CATEGORY_STILL) then Result := 'PIN_CATEGORY_STILL'
  4153. else if IsEqualGuid(GUID,PIN_CATEGORY_TELETEXT) then Result := 'PIN_CATEGORY_TELETEXT'
  4154. else if IsEqualGuid(GUID,PIN_CATEGORY_TIMECODE) then Result := 'PIN_CATEGORY_TIMECODE'
  4155. else if IsEqualGuid(GUID,PIN_CATEGORY_VBI) then Result := 'PIN_CATEGORY_VBI'
  4156. else if IsEqualGuid(GUID,PIN_CATEGORY_VIDEOPORT) then Result := 'PIN_CATEGORY_VIDEOPORT'
  4157. else if IsEqualGuid(GUID,PIN_CATEGORY_VIDEOPORT_VBI) then Result := 'PIN_CATEGORY_VIDEOPORT_VBI'
  4158. else if IsEqualGuid(GUID,CLSID_ACMWrapper) then Result := 'CLSID_ACMWrapper'
  4159. else if IsEqualGuid(GUID,CLSID_AVICo) then Result := 'CLSID_AVICo'
  4160. else if IsEqualGuid(GUID,CLSID_AVIDec) then Result := 'CLSID_AVIDec'
  4161. else if IsEqualGuid(GUID,CLSID_AVIDoc) then Result := 'CLSID_AVIDoc'
  4162. else if IsEqualGuid(GUID,CLSID_AVIDraw) then Result := 'CLSID_AVIDraw'
  4163. else if IsEqualGuid(GUID,CLSID_AVIMIDIRender) then Result := 'CLSID_AVIMIDIRender'
  4164. else if IsEqualGuid(GUID,CLSID_ActiveMovieCategories) then Result := 'CLSID_ActiveMovieCategories'
  4165. else if IsEqualGuid(GUID,CLSID_AnalogVideoDecoderPropertyPage) then Result := 'CLSID_AnalogVideoDecoderPropertyPage'
  4166. else if IsEqualGuid(GUID,CLSID_WMAsfReader) then Result := 'CLSID_WMAsfReader'
  4167. else if IsEqualGuid(GUID,CLSID_WMAsfWriter) then Result := 'CLSID_WMAsfWriter'
  4168. else if IsEqualGuid(GUID,CLSID_AsyncReader) then Result := 'CLSID_AsyncReader'
  4169. else if IsEqualGuid(GUID,CLSID_AudioCompressorCategory) then Result := 'CLSID_AudioCompressorCategory'
  4170. else if IsEqualGuid(GUID,CLSID_AudioInputDeviceCategory) then Result := 'CLSID_AudioInputDeviceCategory'
  4171. else if IsEqualGuid(GUID,CLSID_AudioProperties) then Result := 'CLSID_AudioProperties'
  4172. else if IsEqualGuid(GUID,CLSID_AudioRecord) then Result := 'CLSID_AudioRecord'
  4173. else if IsEqualGuid(GUID,CLSID_AudioRender) then Result := 'CLSID_AudioRender'
  4174. else if IsEqualGuid(GUID,CLSID_AudioRendererCategory) then Result := 'CLSID_AudioRendererCategory'
  4175. else if IsEqualGuid(GUID,CLSID_AviDest) then Result := 'CLSID_AviDest'
  4176. else if IsEqualGuid(GUID,CLSID_AviMuxProptyPage) then Result := 'CLSID_AviMuxProptyPage'
  4177. else if IsEqualGuid(GUID,CLSID_AviMuxProptyPage1) then Result := 'CLSID_AviMuxProptyPage1'
  4178. else if IsEqualGuid(GUID,CLSID_AviReader) then Result := 'CLSID_AviReader'
  4179. else if IsEqualGuid(GUID,CLSID_AviSplitter) then Result := 'CLSID_AviSplitter'
  4180. else if IsEqualGuid(GUID,CLSID_CAcmCoClassManager) then Result := 'CLSID_CAcmCoClassManager'
  4181. else if IsEqualGuid(GUID,CLSID_CDeviceMoniker) then Result := 'CLSID_CDeviceMoniker'
  4182. else if IsEqualGuid(GUID,CLSID_CIcmCoClassManager) then Result := 'CLSID_CIcmCoClassManager'
  4183. else if IsEqualGuid(GUID,CLSID_CMidiOutClassManager) then Result := 'CLSID_CMidiOutClassManager'
  4184. else if IsEqualGuid(GUID,CLSID_CMpegAudioCodec) then Result := 'CLSID_CMpegAudioCodec'
  4185. else if IsEqualGuid(GUID,CLSID_CMpegVideoCodec) then Result := 'CLSID_CMpegVideoCodec'
  4186. else if IsEqualGuid(GUID,CLSID_CQzFilterClassManager) then Result := 'CLSID_CQzFilterClassManager'
  4187. else if IsEqualGuid(GUID,CLSID_CVidCapClassManager) then Result := 'CLSID_CVidCapClassManager'
  4188. else if IsEqualGuid(GUID,CLSID_CWaveOutClassManager) then Result := 'CLSID_CWaveOutClassManager'
  4189. else if IsEqualGuid(GUID,CLSID_CWaveinClassManager) then Result := 'CLSID_CWaveinClassManager'
  4190. else if IsEqualGuid(GUID,CLSID_CameraControlPropertyPage) then Result := 'CLSID_CameraControlPropertyPage'
  4191. else if IsEqualGuid(GUID,CLSID_CaptureGraphBuilder) then Result := 'CLSID_CaptureGraphBuilder'
  4192. else if IsEqualGuid(GUID,CLSID_CaptureProperties) then Result := 'CLSID_CaptureProperties'
  4193. else if IsEqualGuid(GUID,CLSID_Colour) then Result := 'CLSID_Colour'
  4194. else if IsEqualGuid(GUID,CLSID_CrossbarFilterPropertyPage) then Result := 'CLSID_CrossbarFilterPropertyPage'
  4195. else if IsEqualGuid(GUID,CLSID_DSoundRender) then Result := 'CLSID_DSoundRender'
  4196. else if IsEqualGuid(GUID,CLSID_DVDHWDecodersCategory) then Result := 'CLSID_DVDHWDecodersCategory'
  4197. else if IsEqualGuid(GUID,CLSID_DVDNavigator) then Result := 'CLSID_DVDNavigator'
  4198. else if IsEqualGuid(GUID,CLSID_DVDecPropertiesPage) then Result := 'CLSID_DVDecPropertiesPage'
  4199. else if IsEqualGuid(GUID,CLSID_DVEncPropertiesPage) then Result := 'CLSID_DVEncPropertiesPage'
  4200. else if IsEqualGuid(GUID,CLSID_DVMux) then Result := 'CLSID_DVMux'
  4201. else if IsEqualGuid(GUID,CLSID_DVMuxPropertyPage) then Result := 'CLSID_DVMuxPropertyPage'
  4202. else if IsEqualGuid(GUID,CLSID_DVSplitter) then Result := 'CLSID_DVSplitter'
  4203. else if IsEqualGuid(GUID,CLSID_DVVideoCodec) then Result := 'CLSID_DVVideoCodec'
  4204. else if IsEqualGuid(GUID,CLSID_DVVideoEnc) then Result := 'CLSID_DVVideoEnc'
  4205. else if IsEqualGuid(GUID,CLSID_DirectDraw) then Result := 'CLSID_DirectDraw'
  4206. else if IsEqualGuid(GUID,CLSID_DirectDrawClipper) then Result := 'CLSID_DirectDrawClipper'
  4207. else if IsEqualGuid(GUID,CLSID_DirectDrawProperties) then Result := 'CLSID_DirectDrawProperties'
  4208. else if IsEqualGuid(GUID,CLSID_Dither) then Result := 'CLSID_Dither'
  4209. else if IsEqualGuid(GUID,CLSID_DvdGraphBuilder) then Result := 'CLSID_DvdGraphBuilder'
  4210. else if IsEqualGuid(GUID,CLSID_FGControl) then Result := 'CLSID_FGControl'
  4211. else if IsEqualGuid(GUID,CLSID_FileSource) then Result := 'CLSID_FileSource'
  4212. else if IsEqualGuid(GUID,CLSID_FileWriter) then Result := 'CLSID_FileWriter'
  4213. else if IsEqualGuid(GUID,CLSID_FilterGraph) then Result := 'CLSID_FilterGraph'
  4214. else if IsEqualGuid(GUID,CLSID_FilterGraphNoThread) then Result := 'CLSID_FilterGraphNoThread'
  4215. else if IsEqualGuid(GUID,CLSID_FilterMapper) then Result := 'CLSID_FilterMapper'
  4216. else if IsEqualGuid(GUID,CLSID_FilterMapper2) then Result := 'CLSID_FilterMapper2'
  4217. else if IsEqualGuid(GUID,CLSID_InfTee) then Result := 'CLSID_InfTee'
  4218. else if IsEqualGuid(GUID,CLSID_LegacyAmFilterCategory) then Result := 'CLSID_LegacyAmFilterCategory'
  4219. else if IsEqualGuid(GUID,CLSID_Line21Decoder) then Result := 'CLSID_Line21Decoder'
  4220. else if IsEqualGuid(GUID,CLSID_MOVReader) then Result := 'CLSID_MOVReader'
  4221. else if IsEqualGuid(GUID,CLSID_MPEG1Doc) then Result := 'CLSID_MPEG1Doc'
  4222. else if IsEqualGuid(GUID,CLSID_MPEG1PacketPlayer) then Result := 'CLSID_MPEG1PacketPlayer'
  4223. else if IsEqualGuid(GUID,CLSID_MPEG1Splitter) then Result := 'CLSID_MPEG1Splitter'
  4224. else if IsEqualGuid(GUID,CLSID_MediaPropertyBag) then Result := 'CLSID_MediaPropertyBag'
  4225. else if IsEqualGuid(GUID,CLSID_MemoryAllocator) then Result := 'CLSID_MemoryAllocator'
  4226. else if IsEqualGuid(GUID,CLSID_MidiRendererCategory) then Result := 'CLSID_MidiRendererCategory'
  4227. else if IsEqualGuid(GUID,CLSID_ModexProperties) then Result := 'CLSID_ModexProperties'
  4228. else if IsEqualGuid(GUID,CLSID_ModexRenderer) then Result := 'CLSID_ModexRenderer'
  4229. else if IsEqualGuid(GUID,CLSID_OverlayMixer) then Result := 'CLSID_OverlayMixer'
  4230. else if IsEqualGuid(GUID,CLSID_PerformanceProperties) then Result := 'CLSID_PerformanceProperties'
  4231. else if IsEqualGuid(GUID,CLSID_PersistMonikerPID) then Result := 'CLSID_PersistMonikerPID'
  4232. else if IsEqualGuid(GUID,CLSID_ProtoFilterGraph) then Result := 'CLSID_ProtoFilterGraph'
  4233. else if IsEqualGuid(GUID,CLSID_QualityProperties) then Result := 'CLSID_QualityProperties'
  4234. else if IsEqualGuid(GUID,CLSID_SeekingPassThru) then Result := 'CLSID_SeekingPassThru'
  4235. else if IsEqualGuid(GUID,CLSID_SmartTee) then Result := 'CLSID_SmartTee'
  4236. else if IsEqualGuid(GUID,CLSID_SystemClock) then Result := 'CLSID_SystemClock'
  4237. else if IsEqualGuid(GUID,CLSID_SystemDeviceEnum) then Result := 'CLSID_SystemDeviceEnum'
  4238. else if IsEqualGuid(GUID,CLSID_TVAudioFilterPropertyPage) then Result := 'CLSID_TVAudioFilterPropertyPage'
  4239. else if IsEqualGuid(GUID,CLSID_TVTunerFilterPropertyPage) then Result := 'CLSID_TVTunerFilterPropertyPage'
  4240. else if IsEqualGuid(GUID,CLSID_TextRender) then Result := 'CLSID_TextRender'
  4241. else if IsEqualGuid(GUID,CLSID_URLReader) then Result := 'CLSID_URLReader'
  4242. else if IsEqualGuid(GUID,CLSID_VBISurfaces) then Result := 'CLSID_VBISurfaces'
  4243. else if IsEqualGuid(GUID,CLSID_VPObject) then Result := 'CLSID_VPObject'
  4244. else if IsEqualGuid(GUID,CLSID_VPVBIObject) then Result := 'CLSID_VPVBIObject'
  4245. else if IsEqualGuid(GUID,CLSID_VfwCapture) then Result := 'CLSID_VfwCapture'
  4246. else if IsEqualGuid(GUID,CLSID_VideoCompressorCategory) then Result := 'CLSID_VideoCompressorCategory'
  4247. else if IsEqualGuid(GUID,CLSID_VideoInputDeviceCategory) then Result := 'CLSID_VideoInputDeviceCategory'
  4248. else if IsEqualGuid(GUID,CLSID_VideoProcAmpPropertyPage) then Result := 'CLSID_VideoProcAmpPropertyPage'
  4249. else if IsEqualGuid(GUID,CLSID_VideoRenderer) then Result := 'CLSID_VideoRenderer'
  4250. else if IsEqualGuid(GUID,CLSID_VideoStreamConfigPropertyPage) then Result := 'CLSID_VideoStreamConfigPropertyPage'
  4251. else if IsEqualGuid(GUID,CLSID_WMMUTEX_Language) then Result := 'CLSID_WMMUTEX_Language'
  4252. else if IsEqualGuid(GUID,CLSID_WMMUTEX_Bitrate) then Result := 'CLSID_WMMUTEX_Bitrate'
  4253. else if IsEqualGuid(GUID,CLSID_WMMUTEX_Presentation) then Result := 'CLSID_WMMUTEX_Presentation'
  4254. else if IsEqualGuid(GUID,CLSID_WMMUTEX_Unknown) then Result := 'CLSID_WMMUTEX_Unknown'
  4255. else if IsEqualGuid(GUID,CLSID_WMBandwidthSharing_Exclusive) then Result := 'CLSID_WMBandwidthSharing_Exclusive'
  4256. else if IsEqualGuid(GUID,CLSID_WMBandwidthSharing_Partial) then Result := 'CLSID_WMBandwidthSharing_Partial'
  4257. else if IsEqualGuid(GUID,FORMAT_AnalogVideo) then Result := 'FORMAT_AnalogVideo'
  4258. else if IsEqualGuid(GUID,FORMAT_DVD_LPCMAudio) then Result := 'FORMAT_DVD_LPCMAudio'
  4259. else if IsEqualGuid(GUID,FORMAT_DolbyAC3) then Result := 'FORMAT_DolbyAC3'
  4260. else if IsEqualGuid(GUID,FORMAT_DvInfo) then Result := 'FORMAT_DvInfo'
  4261. else if IsEqualGuid(GUID,FORMAT_MPEG2Audio) then Result := 'FORMAT_MPEG2Audio'
  4262. else if IsEqualGuid(GUID,FORMAT_MPEG2Video) then Result := 'FORMAT_MPEG2Video'
  4263. else if IsEqualGuid(GUID,FORMAT_MPEG2_VIDEO) then Result := 'FORMAT_MPEG2_VIDEO'
  4264. else if IsEqualGuid(GUID,FORMAT_MPEGStreams) then Result := 'FORMAT_MPEGStreams'
  4265. else if IsEqualGuid(GUID,FORMAT_MPEGVideo) then Result := 'FORMAT_MPEGVideo'
  4266. else if IsEqualGuid(GUID,FORMAT_None) then Result := 'FORMAT_None'
  4267. else if IsEqualGuid(GUID,FORMAT_VIDEOINFO2) then Result := 'FORMAT_VIDEOINFO2'
  4268. else if IsEqualGuid(GUID,FORMAT_VideoInfo) then Result := 'FORMAT_VideoInfo'
  4269. else if IsEqualGuid(GUID,FORMAT_VideoInfo2) then Result := 'FORMAT_VideoInfo2'
  4270. else if IsEqualGuid(GUID,FORMAT_WaveFormatEx) then Result := 'FORMAT_WaveFormatEx'
  4271. else if IsEqualGuid(GUID,TIME_FORMAT_BYTE) then Result := 'TIME_FORMAT_BYTE'
  4272. else if IsEqualGuid(GUID,TIME_FORMAT_FIELD) then Result := 'TIME_FORMAT_FIELD'
  4273. else if IsEqualGuid(GUID,TIME_FORMAT_FRAME) then Result := 'TIME_FORMAT_FRAME'
  4274. else if IsEqualGuid(GUID,TIME_FORMAT_MEDIA_TIME) then Result := 'TIME_FORMAT_MEDIA_TIME'
  4275. else if IsEqualGuid(GUID,TIME_FORMAT_SAMPLE) then Result := 'TIME_FORMAT_SAMPLE'
  4276. else if IsEqualGuid(GUID,AMPROPSETID_Pin) then Result := 'AMPROPSETID_Pin'
  4277. else if IsEqualGuid(GUID,AM_INTERFACESETID_Standard) then Result := 'AM_INTERFACESETID_Standard'
  4278. else if IsEqualGuid(GUID,AM_KSCATEGORY_AUDIO) then Result := 'AM_KSCATEGORY_AUDIO'
  4279. else if IsEqualGuid(GUID,AM_KSCATEGORY_CAPTURE) then Result := 'AM_KSCATEGORY_CAPTURE'
  4280. else if IsEqualGuid(GUID,AM_KSCATEGORY_CROSSBAR) then Result := 'AM_KSCATEGORY_CROSSBAR'
  4281. else if IsEqualGuid(GUID,AM_KSCATEGORY_DATACOMPRESSOR) then Result := 'AM_KSCATEGORY_DATACOMPRESSOR'
  4282. else if IsEqualGuid(GUID,AM_KSCATEGORY_RENDER) then Result := 'AM_KSCATEGORY_RENDER'
  4283. else if IsEqualGuid(GUID,AM_KSCATEGORY_TVAUDIO) then Result := 'AM_KSCATEGORY_TVAUDIO'
  4284. else if IsEqualGuid(GUID,AM_KSCATEGORY_TVTUNER) then Result := 'AM_KSCATEGORY_TVTUNER'
  4285. else if IsEqualGuid(GUID,AM_KSCATEGORY_VIDEO) then Result := 'AM_KSCATEGORY_VIDEO'
  4286. else if IsEqualGuid(GUID,AM_KSPROPSETID_AC3) then Result := 'AM_KSPROPSETID_AC3'
  4287. else if IsEqualGuid(GUID,AM_KSPROPSETID_CopyProt) then Result := 'AM_KSPROPSETID_CopyProt'
  4288. else if IsEqualGuid(GUID,AM_KSPROPSETID_DvdSubPic) then Result := 'AM_KSPROPSETID_DvdSubPic'
  4289. else if IsEqualGuid(GUID,AM_KSPROPSETID_TSRateChange) then Result := 'AM_KSPROPSETID_TSRateChange'
  4290. else if IsEqualGuid(GUID,IID_IAMDirectSound) then Result := 'IID_IAMDirectSound'
  4291. else if IsEqualGuid(GUID,IID_IAMLine21Decoder) then Result := 'IID_IAMLine21Decoder'
  4292. else if IsEqualGuid(GUID,IID_IBaseVideoMixer) then Result := 'IID_IBaseVideoMixer'
  4293. else if IsEqualGuid(GUID,IID_IDDVideoPortContainer) then Result := 'IID_IDDVideoPortContainer'
  4294. else if IsEqualGuid(GUID,IID_IDirectDraw) then Result := 'IID_IDirectDraw'
  4295. else if IsEqualGuid(GUID,IID_IDirectDraw2) then Result := 'IID_IDirectDraw2'
  4296. else if IsEqualGuid(GUID,IID_IDirectDrawClipper) then Result := 'IID_IDirectDrawClipper'
  4297. else if IsEqualGuid(GUID,IID_IDirectDrawColorControl) then Result := 'IID_IDirectDrawColorControl'
  4298. else if IsEqualGuid(GUID,IID_IDirectDrawKernel) then Result := 'IID_IDirectDrawKernel'
  4299. else if IsEqualGuid(GUID,IID_IDirectDrawPalette) then Result := 'IID_IDirectDrawPalette'
  4300. else if IsEqualGuid(GUID,IID_IDirectDrawSurface) then Result := 'IID_IDirectDrawSurface'
  4301. else if IsEqualGuid(GUID,IID_IDirectDrawSurface2) then Result := 'IID_IDirectDrawSurface2'
  4302. else if IsEqualGuid(GUID,IID_IDirectDrawSurface3) then Result := 'IID_IDirectDrawSurface3'
  4303. else if IsEqualGuid(GUID,IID_IDirectDrawSurfaceKernel) then Result := 'IID_IDirectDrawSurfaceKernel'
  4304. else if IsEqualGuid(GUID,IID_IDirectDrawVideo) then Result := 'IID_IDirectDrawVideo'
  4305. else if IsEqualGuid(GUID,IID_IFullScreenVideo) then Result := 'IID_IFullScreenVideo'
  4306. else if IsEqualGuid(GUID,IID_IFullScreenVideoEx) then Result := 'IID_IFullScreenVideoEx'
  4307. else if IsEqualGuid(GUID,IID_IKsDataTypeHandler) then Result := 'IID_IKsDataTypeHandler'
  4308. else if IsEqualGuid(GUID,IID_IKsInterfaceHandler) then Result := 'IID_IKsInterfaceHandler'
  4309. else if IsEqualGuid(GUID,IID_IKsPin) then Result := 'IID_IKsPin'
  4310. else if IsEqualGuid(GUID,IID_IMixerPinConfig) then Result := 'IID_IMixerPinConfig'
  4311. else if IsEqualGuid(GUID,IID_IMixerPinConfig2) then Result := 'IID_IMixerPinConfig2'
  4312. else if IsEqualGuid(GUID,IID_IMpegAudioDecoder) then Result := 'IID_IMpegAudioDecoder'
  4313. else if IsEqualGuid(GUID,IID_IQualProp) then Result := 'IID_IQualProp'
  4314. else if IsEqualGuid(GUID,IID_IVPConfig) then Result := 'IID_IVPConfig'
  4315. else if IsEqualGuid(GUID,IID_IVPControl) then Result := 'IID_IVPControl'
  4316. else if IsEqualGuid(GUID,IID_IVPNotify) then Result := 'IID_IVPNotify'
  4317. else if IsEqualGuid(GUID,IID_IVPNotify2) then Result := 'IID_IVPNotify2'
  4318. else if IsEqualGuid(GUID,IID_IVPObject) then Result := 'IID_IVPObject'
  4319. else if IsEqualGuid(GUID,IID_IVPVBIConfig) then Result := 'IID_IVPVBIConfig'
  4320. else if IsEqualGuid(GUID,IID_IVPVBINotify) then Result := 'IID_IVPVBINotify'
  4321. else if IsEqualGuid(GUID,IID_IVPVBIObject) then Result := 'IID_IVPVBIObject'
  4322. else if IsEqualGuid(GUID,LOOK_DOWNSTREAM_ONLY) then Result := 'LOOK_DOWNSTREAM_ONLY'
  4323. else if IsEqualGuid(GUID,LOOK_UPSTREAM_ONLY) then Result := 'LOOK_UPSTREAM_ONLY'
  4324. else Result := '';
  4325. end;
  4326. // milenko end
  4327. // milenko start (usefull functions to get linear amplification)
  4328. // improved by XXX
  4329. function GetBasicAudioVolume(Value : integer) : integer;
  4330. begin
  4331. Inc(Value, 10000);
  4332. Result := Round(Exp(Value / 1085.73) - 1);
  4333. end;
  4334. function SetBasicAudioVolume(Value : integer) : integer;
  4335. begin
  4336. Inc(Value);
  4337. Result := Round(1085.73*ln(Value)) - 10000;
  4338. end;
  4339. function GetBasicAudioPan(Value : integer) : integer;
  4340. begin
  4341. Result := Round(Exp(abs(Value) / 1085.73) - 1);
  4342. if Value <= 0 then Result := -Result;
  4343. end;
  4344. function SetBasicAudioPan(Value : integer) : integer;
  4345. begin
  4346. Result := Round(1085.73*ln(abs(Value)+1));
  4347. if Value >= 0 then Result := -Result;
  4348. end;
  4349. // milenko end
  4350. // milenok start (yet another delphi5 compatibility ...)
  4351. {$IFDEF VER130}
  4352. function StringToGUID(const S: string): TGUID;
  4353. begin
  4354. if not Succeeded(CLSIDFromString(PWideChar(WideString(S)), Result))
  4355. then raise Exception.Create('StringToGUID: Error converting String');
  4356. end;
  4357. function GUIDToString(const GUID: TGUID): string;
  4358. var
  4359. P: PWideChar;
  4360. begin
  4361. if not Succeeded(StringFromCLSID(GUID, P))
  4362. then raise Exception.Create('GUIDToString: Error converting GUID');
  4363. Result := P;
  4364. CoTaskMemFree(P);
  4365. end;
  4366. function EnsureRange(const AValue, AMin, AMax: Integer): Integer;
  4367. begin
  4368. Result := AValue;
  4369. assert(AMin <= AMax);
  4370. if Result < AMin then
  4371. Result := AMin;
  4372. if Result > AMax then
  4373. Result := AMax;
  4374. end;
  4375. {$ENDIF}
  4376. // milenko end
  4377. const
  4378. SectionLengthMask = $FFF; // 0000111111111111
  4379. ReservedMask = $3000; // 0011000000000000
  4380. PrivateIndicatorMask = $4000; // 0100000000000000
  4381. SectionSyntaxIndicatorMask = $8000; // 1000000000000000
  4382. function MPEGHeaderBitsGetSectionLength(Header: PMPEGHeaderBits): WORD;
  4383. begin
  4384. Result := Header.Bits and SectionLengthMask;
  4385. end;
  4386. function MPEGHeaderBitsGetReserved(Header: PMPEGHeaderBits): WORD;
  4387. begin
  4388. Result := (Header.Bits and ReservedMask) shr 12;
  4389. end;
  4390. function MPEGHeaderBitsGetPrivateIndicator(Header: PMPEGHeaderBits): WORD;
  4391. begin
  4392. Result := (Header.Bits and PrivateIndicatorMask) shr 14;
  4393. end;
  4394. function MPEGHeaderBitsGetSectionSyntaxIndicator(Header: PMPEGHeaderBits): WORD;
  4395. begin
  4396. Result := (Header.Bits and SectionSyntaxIndicatorMask) shr 15;
  4397. end;
  4398. procedure MPEGHeaderBitsSetSectionLength(Header: PMPEGHeaderBits; AValue: WORD);
  4399. begin
  4400. Header.Bits := Header.Bits or (AValue and SectionLengthMask);
  4401. end;
  4402. procedure MPEGHeaderBitsSetReserved(Header: PMPEGHeaderBits; AValue: WORD);
  4403. begin
  4404. Header.Bits := Header.Bits or ((AValue shl 12) and ReservedMask);
  4405. end;
  4406. procedure MPEGHeaderBitsSetPrivateIndicator(Header: PMPEGHeaderBits; AValue: WORD);
  4407. begin
  4408. Header.Bits := Header.Bits or ((AValue shl 14) and PrivateIndicatorMask);
  4409. end;
  4410. procedure MPEGHeaderBitsSetSectionSyntaxIndicator(Header: PMPEGHeaderBits; AValue: WORD);
  4411. begin
  4412. Header.Bits := Header.Bits or ((AValue shl 15) and SectionSyntaxIndicatorMask);
  4413. end;
  4414. const
  4415. PIDBitsReservedMask = $7; // 0000000000000111
  4416. PIDBitsProgramId = $FFF8; // 1111111111111000
  4417. function PIDBitsGetReserved(PIDBits: PPIDBits): WORD;
  4418. begin
  4419. Result := PIDBits.Bits and PIDBitsReservedMask;
  4420. end;
  4421. function PIDBitsGetProgramId(PIDBits: PPIDBits): WORD;
  4422. begin
  4423. Result := (PIDBits.Bits and PIDBitsProgramId) shr 3;
  4424. end;
  4425. procedure PIDBitsSetReserved(PIDBits: PPIDBits; AValue: WORD);
  4426. begin
  4427. PIDBits.Bits := PIDBits.Bits or (AValue and PIDBitsReservedMask);
  4428. end;
  4429. procedure PIDBitsSetProgramId(PIDBits: PPIDBits; AValue: WORD);
  4430. begin
  4431. PIDBits.Bits := PIDBits.Bits or ((AValue shl 3) and PIDBitsProgramId);
  4432. end;
  4433. const
  4434. MHBCurrentNextIndicator = $1; // 00000001
  4435. MHBVersionNumber = $3E; // 00111110
  4436. MHBReserved = $C0; // 11000000
  4437. function MPEGHeaderVersionBitsGetCurrentNextIndicator(MPEGHeaderVersionBits: PMPEGHeaderVersionBits): Byte;
  4438. begin
  4439. Result := MPEGHeaderVersionBits.Bits and MHBCurrentNextIndicator;
  4440. end;
  4441. function MPEGHeaderVersionBitsGetVersionNumber(MPEGHeaderVersionBits: PMPEGHeaderVersionBits): Byte;
  4442. begin
  4443. Result := (MPEGHeaderVersionBits.Bits and MHBVersionNumber) shr 1;
  4444. end;
  4445. function MPEGHeaderVersionBitsGetReserved(MPEGHeaderVersionBits: PMPEGHeaderVersionBits): Byte;
  4446. begin
  4447. Result := (MPEGHeaderVersionBits.Bits and MHBReserved) shr 6;
  4448. end;
  4449. procedure MPEGHeaderVersionBitsSetCurrentNextIndicator(MPEGHeaderVersionBits: PMPEGHeaderVersionBits; AValue: Byte);
  4450. begin
  4451. MPEGHeaderVersionBits.Bits := MPEGHeaderVersionBits.Bits or (AValue and MHBCurrentNextIndicator);
  4452. end;
  4453. procedure MPEGHeaderVersionBitsSetVersionNumber(MPEGHeaderVersionBits: PMPEGHeaderVersionBits; AValue: Byte);
  4454. begin
  4455. MPEGHeaderVersionBits.Bits := MPEGHeaderVersionBits.Bits or ((AValue shl 1) and MHBVersionNumber);
  4456. end;
  4457. procedure MPEGHeaderVersionBitsSetReserved(MPEGHeaderVersionBits: PMPEGHeaderVersionBits; AValue: Byte);
  4458. begin
  4459. MPEGHeaderVersionBits.Bits := MPEGHeaderVersionBits.Bits or ((AValue shl 6) and MHBReserved);
  4460. end;
  4461. end.