| 1 | /* BoCA - BonkEnc Component Architecture |
| 2 | * Copyright (C) 2007-2026 Robert Kausch <[email protected]> |
| 3 | * |
| 4 | * This program is free software; you can redistribute it and/or |
| 5 | * modify it under the terms of the GNU General Public License as |
| 6 | * published by the Free Software Foundation, either version 2 of |
| 7 | * the License, or (at your option) any later version. |
| 8 | * |
| 9 | * THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR |
| 10 | * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED |
| 11 | * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. */ |
| 12 | |
| 13 | #include <boca.h> |
| 14 | #include "dllinterface.h" |
| 15 | |
| 16 | using namespace BoCA; |
| 17 | |
| 18 | VOGETAACENCAPI ex_voGetAACEncAPI = NIL; |
| 19 | |
| 20 | CMNMEMALLOC ex_cmnMemAlloc = NIL; |
| 21 | CMNMEMFREE ex_cmnMemFree = NIL; |
| 22 | CMNMEMSET ex_cmnMemSet = NIL; |
| 23 | CMNMEMCOPY ex_cmnMemCopy = NIL; |
| 24 | CMNMEMCHECK ex_cmnMemCheck = NIL; |
| 25 | CMNMEMCOMPARE ex_cmnMemCompare = NIL; |
| 26 | CMNMEMMOVE ex_cmnMemMove = NIL; |
| 27 | |
| 28 | MP4CREATECALLBACKS ex_MP4CreateCallbacks = NIL; |
| 29 | MP4CLOSE ex_MP4Close = NIL; |
| 30 | MP4OPTIMIZE ex_MP4Optimize = NIL; |
| 31 | |
| 32 | MP4SETTRACKESCONFIGURATION ex_MP4SetTrackESConfiguration = NIL; |
| 33 | MP4SETTRACKINTEGERPROPERTY ex_MP4SetTrackIntegerProperty = NIL; |
| 34 | MP4SETAUDIOPROFILELEVEL ex_MP4SetAudioProfileLevel = NIL; |
| 35 | MP4ADDAUDIOTRACK ex_MP4AddAudioTrack = NIL; |
| 36 | MP4WRITESAMPLE ex_MP4WriteSample = NIL; |
| 37 | |
| 38 | MP4ITMFITEMALLOC ex_MP4ItmfItemAlloc = NIL; |
| 39 | MP4ITMFITEMFREE ex_MP4ItmfItemFree = NIL; |
| 40 | MP4ITMFADDITEM ex_MP4ItmfAddItem = NIL; |
| 41 | |
| 42 | DynamicLoader *voaacencdll = NIL; |
| 43 | DynamicLoader *mp4v2dll = NIL; |
| 44 | |
| 45 | Bool LoadVOAACEncDLL() |
| 46 | { |
| 47 | voaacencdll = BoCA::Utilities::LoadCodecDLL("vo-aacenc"); |
| 48 | |
| 49 | if (voaacencdll == NIL) return False; |
| 50 | |
| 51 | ex_voGetAACEncAPI = (VOGETAACENCAPI) voaacencdll->GetFunctionAddress("voGetAACEncAPI"); |
| 52 | |
| 53 | ex_cmnMemAlloc = (CMNMEMALLOC) voaacencdll->GetFunctionAddress("cmnMemAlloc"); |
| 54 | ex_cmnMemFree = (CMNMEMFREE) voaacencdll->GetFunctionAddress("cmnMemFree"); |
| 55 | ex_cmnMemSet = (CMNMEMSET) voaacencdll->GetFunctionAddress("cmnMemSet"); |
| 56 | ex_cmnMemCopy = (CMNMEMCOPY) voaacencdll->GetFunctionAddress("cmnMemCopy"); |
| 57 | ex_cmnMemCheck = (CMNMEMCHECK) voaacencdll->GetFunctionAddress("cmnMemCheck"); |
| 58 | ex_cmnMemCompare = (CMNMEMCOMPARE) voaacencdll->GetFunctionAddress("cmnMemCompare"); |
| 59 | ex_cmnMemMove = (CMNMEMMOVE) voaacencdll->GetFunctionAddress("cmnMemMove"); |
| 60 | |
| 61 | if (ex_voGetAACEncAPI == NIL || |
| 62 | |
| 63 | ex_cmnMemAlloc == NIL || |
| 64 | ex_cmnMemFree == NIL || |
| 65 | ex_cmnMemSet == NIL || |
| 66 | ex_cmnMemCopy == NIL || |
| 67 | ex_cmnMemCheck == NIL || |
| 68 | ex_cmnMemCompare == NIL || |
| 69 | ex_cmnMemMove == NIL) { FreeVOAACEncDLL(); return False; } |
| 70 | |
| 71 | return True; |
| 72 | } |
| 73 | |
| 74 | Void FreeVOAACEncDLL() |
| 75 | { |
| 76 | BoCA::Utilities::FreeCodecDLL(voaacencdll); |
| 77 | |
| 78 | voaacencdll = NIL; |
| 79 | } |
| 80 | |
| 81 | Bool LoadMP4v2DLL() |
| 82 | { |
| 83 | mp4v2dll = BoCA::Utilities::LoadCodecDLL("mp4v2"); |
| 84 | |
| 85 | if (mp4v2dll == NIL) return False; |
| 86 | |
| 87 | ex_MP4CreateCallbacks = (MP4CREATECALLBACKS) mp4v2dll->GetFunctionAddress("MP4CreateCallbacks"); |
| 88 | ex_MP4Close = (MP4CLOSE) mp4v2dll->GetFunctionAddress("MP4Close"); |
| 89 | ex_MP4Optimize = (MP4OPTIMIZE) mp4v2dll->GetFunctionAddress("MP4Optimize"); |
| 90 | |
| 91 | ex_MP4SetTrackESConfiguration = (MP4SETTRACKESCONFIGURATION) mp4v2dll->GetFunctionAddress("MP4SetTrackESConfiguration"); |
| 92 | ex_MP4SetTrackIntegerProperty = (MP4SETTRACKINTEGERPROPERTY) mp4v2dll->GetFunctionAddress("MP4SetTrackIntegerProperty"); |
| 93 | ex_MP4SetAudioProfileLevel = (MP4SETAUDIOPROFILELEVEL) mp4v2dll->GetFunctionAddress("MP4SetAudioProfileLevel"); |
| 94 | ex_MP4AddAudioTrack = (MP4ADDAUDIOTRACK) mp4v2dll->GetFunctionAddress("MP4AddAudioTrack"); |
| 95 | ex_MP4WriteSample = (MP4WRITESAMPLE) mp4v2dll->GetFunctionAddress("MP4WriteSample"); |
| 96 | |
| 97 | ex_MP4ItmfItemAlloc = (MP4ITMFITEMALLOC) mp4v2dll->GetFunctionAddress("MP4ItmfItemAlloc"); |
| 98 | ex_MP4ItmfItemFree = (MP4ITMFITEMFREE) mp4v2dll->GetFunctionAddress("MP4ItmfItemFree"); |
| 99 | ex_MP4ItmfAddItem = (MP4ITMFADDITEM) mp4v2dll->GetFunctionAddress("MP4ItmfAddItem"); |
| 100 | |
| 101 | if (ex_MP4CreateCallbacks == NIL || |
| 102 | ex_MP4Close == NIL || |
| 103 | ex_MP4Optimize == NIL || |
| 104 | |
| 105 | ex_MP4SetTrackESConfiguration == NIL || |
| 106 | ex_MP4SetTrackIntegerProperty == NIL || |
| 107 | ex_MP4SetAudioProfileLevel == NIL || |
| 108 | ex_MP4AddAudioTrack == NIL || |
| 109 | ex_MP4WriteSample == NIL || |
| 110 | |
| 111 | ex_MP4ItmfItemAlloc == NIL || |
| 112 | ex_MP4ItmfItemFree == NIL || |
| 113 | ex_MP4ItmfAddItem == NIL) { FreeMP4v2DLL(); return False; } |
| 114 | |
| 115 | return True; |
| 116 | } |
| 117 | |
| 118 | Void FreeMP4v2DLL() |
| 119 | { |
| 120 | BoCA::Utilities::FreeCodecDLL(mp4v2dll); |
| 121 | |
| 122 | mp4v2dll = NIL; |
| 123 | } |