| 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 | AACENCOPEN ex_aacEncOpen = NIL; |
| 19 | AACENCCLOSE ex_aacEncClose = NIL; |
| 20 | AACENCENCODE ex_aacEncEncode = NIL; |
| 21 | AACENCINFO ex_aacEncInfo = NIL; |
| 22 | AACENCGETLIBINFO ex_aacEncGetLibInfo = NIL; |
| 23 | AACENCODER_GETPARAM ex_aacEncoder_GetParam = NIL; |
| 24 | AACENCODER_SETPARAM ex_aacEncoder_SetParam = NIL; |
| 25 | |
| 26 | MP4CREATECALLBACKS ex_MP4CreateCallbacks = NIL; |
| 27 | MP4CLOSE ex_MP4Close = NIL; |
| 28 | MP4OPTIMIZE ex_MP4Optimize = NIL; |
| 29 | |
| 30 | MP4SETTRACKESCONFIGURATION ex_MP4SetTrackESConfiguration = NIL; |
| 31 | MP4SETTRACKINTEGERPROPERTY ex_MP4SetTrackIntegerProperty = NIL; |
| 32 | MP4SETAUDIOPROFILELEVEL ex_MP4SetAudioProfileLevel = NIL; |
| 33 | MP4ADDAUDIOTRACK ex_MP4AddAudioTrack = NIL; |
| 34 | MP4WRITESAMPLE ex_MP4WriteSample = NIL; |
| 35 | |
| 36 | MP4ITMFITEMALLOC ex_MP4ItmfItemAlloc = NIL; |
| 37 | MP4ITMFITEMFREE ex_MP4ItmfItemFree = NIL; |
| 38 | MP4ITMFADDITEM ex_MP4ItmfAddItem = NIL; |
| 39 | |
| 40 | DynamicLoader *fdkaacdll = NIL; |
| 41 | DynamicLoader *mp4v2dll = NIL; |
| 42 | |
| 43 | Bool LoadFDKAACDLL() |
| 44 | { |
| 45 | fdkaacdll = BoCA::Utilities::LoadCodecDLL("fdk-aac"); |
| 46 | |
| 47 | if (fdkaacdll == NIL) return False; |
| 48 | |
| 49 | ex_aacEncOpen = (AACENCOPEN) fdkaacdll->GetFunctionAddress("aacEncOpen"); |
| 50 | ex_aacEncClose = (AACENCCLOSE) fdkaacdll->GetFunctionAddress("aacEncClose"); |
| 51 | ex_aacEncEncode = (AACENCENCODE) fdkaacdll->GetFunctionAddress("aacEncEncode"); |
| 52 | ex_aacEncInfo = (AACENCINFO) fdkaacdll->GetFunctionAddress("aacEncInfo"); |
| 53 | ex_aacEncGetLibInfo = (AACENCGETLIBINFO) fdkaacdll->GetFunctionAddress("aacEncGetLibInfo"); |
| 54 | ex_aacEncoder_GetParam = (AACENCODER_GETPARAM) fdkaacdll->GetFunctionAddress("aacEncoder_GetParam"); |
| 55 | ex_aacEncoder_SetParam = (AACENCODER_SETPARAM) fdkaacdll->GetFunctionAddress("aacEncoder_SetParam"); |
| 56 | |
| 57 | if (ex_aacEncOpen == NIL || |
| 58 | ex_aacEncClose == NIL || |
| 59 | ex_aacEncEncode == NIL || |
| 60 | ex_aacEncInfo == NIL || |
| 61 | ex_aacEncGetLibInfo == NIL || |
| 62 | ex_aacEncoder_GetParam == NIL || |
| 63 | ex_aacEncoder_SetParam == NIL) { FreeFDKAACDLL(); return False; } |
| 64 | |
| 65 | return True; |
| 66 | } |
| 67 | |
| 68 | Void FreeFDKAACDLL() |
| 69 | { |
| 70 | BoCA::Utilities::FreeCodecDLL(fdkaacdll); |
| 71 | |
| 72 | fdkaacdll = NIL; |
| 73 | } |
| 74 | |
| 75 | Bool LoadMP4v2DLL() |
| 76 | { |
| 77 | mp4v2dll = BoCA::Utilities::LoadCodecDLL("mp4v2"); |
| 78 | |
| 79 | if (mp4v2dll == NIL) return False; |
| 80 | |
| 81 | ex_MP4CreateCallbacks = (MP4CREATECALLBACKS) mp4v2dll->GetFunctionAddress("MP4CreateCallbacks"); |
| 82 | ex_MP4Close = (MP4CLOSE) mp4v2dll->GetFunctionAddress("MP4Close"); |
| 83 | ex_MP4Optimize = (MP4OPTIMIZE) mp4v2dll->GetFunctionAddress("MP4Optimize"); |
| 84 | |
| 85 | ex_MP4SetTrackESConfiguration = (MP4SETTRACKESCONFIGURATION) mp4v2dll->GetFunctionAddress("MP4SetTrackESConfiguration"); |
| 86 | ex_MP4SetTrackIntegerProperty = (MP4SETTRACKINTEGERPROPERTY) mp4v2dll->GetFunctionAddress("MP4SetTrackIntegerProperty"); |
| 87 | ex_MP4SetAudioProfileLevel = (MP4SETAUDIOPROFILELEVEL) mp4v2dll->GetFunctionAddress("MP4SetAudioProfileLevel"); |
| 88 | ex_MP4AddAudioTrack = (MP4ADDAUDIOTRACK) mp4v2dll->GetFunctionAddress("MP4AddAudioTrack"); |
| 89 | ex_MP4WriteSample = (MP4WRITESAMPLE) mp4v2dll->GetFunctionAddress("MP4WriteSample"); |
| 90 | |
| 91 | ex_MP4ItmfItemAlloc = (MP4ITMFITEMALLOC) mp4v2dll->GetFunctionAddress("MP4ItmfItemAlloc"); |
| 92 | ex_MP4ItmfItemFree = (MP4ITMFITEMFREE) mp4v2dll->GetFunctionAddress("MP4ItmfItemFree"); |
| 93 | ex_MP4ItmfAddItem = (MP4ITMFADDITEM) mp4v2dll->GetFunctionAddress("MP4ItmfAddItem"); |
| 94 | |
| 95 | if (ex_MP4CreateCallbacks == NIL || |
| 96 | ex_MP4Close == NIL || |
| 97 | ex_MP4Optimize == NIL || |
| 98 | |
| 99 | ex_MP4SetTrackESConfiguration == NIL || |
| 100 | ex_MP4SetTrackIntegerProperty == NIL || |
| 101 | ex_MP4SetAudioProfileLevel == NIL || |
| 102 | ex_MP4AddAudioTrack == NIL || |
| 103 | ex_MP4WriteSample == NIL || |
| 104 | |
| 105 | ex_MP4ItmfItemAlloc == NIL || |
| 106 | ex_MP4ItmfItemFree == NIL || |
| 107 | ex_MP4ItmfAddItem == NIL) { FreeMP4v2DLL(); return False; } |
| 108 | |
| 109 | return True; |
| 110 | } |
| 111 | |
| 112 | Void FreeMP4v2DLL() |
| 113 | { |
| 114 | BoCA::Utilities::FreeCodecDLL(mp4v2dll); |
| 115 | |
| 116 | mp4v2dll = NIL; |
| 117 | } |