|
|
Yes, but I saw there C# code, not C++ ... and I need C++, I don't know C# at all.
|
|
|
|
|
|
I want encrypt & decrypt Video file With FFMPEG oflfine mode in hard disk.
I encrypt a Video File (mp4 Extention) by ffmpeg.exe Tools by this Command:
ffmpeg -i SampleVideo_1280x720_1mb.mp4 -vcodec copy -acodec copy
-encryption_scheme cenc-aes-ctr -encryption_key
76a6c65c5ea762046bd749a2e632ccbb -encryption_kid
a7e61c373e219033c21091fa607bf3b8 SampleVideo_1280x720_1mb_encrypted.mp4
for decryption : i want decrypt and play video file (encrypted.mp4) in my player source c++ (ffmpeg base) and *now i dont wnat use decrypt file with command line with ffplay.exe *like this :
ffplay SampleVideo_1280x720_1mb_encrypted.mp4 -decryption_key
76a6c65c5ea762046bd749a2e632ccbb
how i can do decrypt with Write programing code that use FFMPEG api?
thanks in advance.
|
|
|
|
|
DARA ALAVI wrote: how i can do decrypt with Write programing code that use FFMPEG api?
Read/learn the FFMPEG api documentation.
|
|
|
|
|
I searched a lot but did not find anything.
There is no explanation on how to use it.
I did not find a sample..
|
|
|
|
|
Then use the recommended way to decrypt with ffplay.exe
|
|
|
|
|
I do not need ffplay.exe because i downloaded FFMPEG dev and i have written my own player program Which is based on FFMPEG! with QT & C++.
I dont want use ffplay.exe that exist static FFMPEG Folder. .
I want decrypt and play Encrypted File in my player program Through Programing code.
Now how to decrypt encrypted files using FFMPeg API with C++ Programing?
thanks.
|
|
|
|
|
I need to debug some code executing on top of FreeRTOS that runs on an embedded ARM processor and I have no knowledge of FreeRTOS and I was hoping someone here could please help me. Image there are two threads in the entire code, one high-priority communication bus driver and one low-priority application thread. Whenever the application wants to write, it queues a struct onto a queue and when the communication driver sees that there is a struct in the queue, it pulls the struct out and starts writing over the communication bus according to the instructions in the struct. Now, let's assume the application first wants to write 1 byte and then shortly thereafter wants to write 2 bytes and the bytes to write are located on the stack and NOT in static variables/arrays. What the recommended way to handle this? Clearly the 2nd struct would be 1 byte larger than the 1st struct, but they both need to go into the same queue.
modified 12-Jul-20 16:14pm.
|
|
|
|
|
I have had a similar issue in the past, and created a struct like this:
struct sq
{
int nbytes;
byte queueItems[1];
}
When a struct is required it is a simple matter to allocate it dynamically from the struct size plus the number of bytes to be added to the queueItems array. The nbytes item can then be filled in with the number of bytes in the array to be handled elsewhere.
|
|
|
|
|
Generally you would have a circular queue of pointers to struct on the transmission queue. You don't want to be copying data around when you don't have to and it means the transmission queue is always just a pointer that the transmission sender can check what the pointer points to. In your struct you could have for example a field which would be "size to send" and then the data. You either free the struct after sending if dynamic, or clear a flag in the struct to mark it free for reuse if using static structs.
As you are feeding two threads into one queue you will also need to put a binary semaphore on queue access.
In vino veritas
|
|
|
|
|
I am writing code for an ARM processor and compiling with GCC. I have done some C# programming and there you're allowed to declare delegates inside structures. What's the closest thing I can achieve the same thing in my ARM-project? For example, it would great if I could write a state machine like this:
typedef void (*readDataResultCallback_t)(uint8_t* readData, uint16_t sizeOfReadData);
typedef enum {
STATE1 = 0,
STATE2 = 1,
STATE3 = 2,
} stateMachineState_e;
typedef struct __attribute__((__packed__)) {
stateMachineState_e state;
uint32_t startAddr;
uint16_t numRegsToRead;
readDataResultCallback_t readDataResultCallback;
} stateMachineStep_s;
static stateMachineState_e state = STATE1;
stateMachineStep_s stateMachineSteps[3] = {
{STATE1, 10, 2, { (uint8_t* readData, uint16_t sizeOfReadData) {
if (stringCompare(readData, "AB") {
... Do stuff here...
state = STATE_2;
} else {
... Do stuff here...
state = STATE_3;
}}},
{STATE2, 20, 3, { (uint8_t* readData, uint16_t sizeOfReadData) {
if (stringCompare(readData, "ABC") {
... Do stuff here...
state = STATE_1;
} else {
... Do stuff here...
state = STATE_3;
}}},
{STATE3, 30, 4, { (uint8_t* readData, uint16_t sizeOfReadData) {
if (stringCompare(readData, "ABCD") {
... Do stuff here...
state = STATE_3;
} else {
... Do stuff here...
state = STATE_2;
}}},
}; Do I need to write my own pre-compile code interpreter/generator script that would place the anonymous code in functions outside the stateMachineStep_s array or is there something clever I can do (perhaps with macros or C++)?
modified 10-Jul-20 7:38am.
|
|
|
|
|
the
readDataResultCallback member of your structure is just a fancy pointer, either 32 or 64 bits long depending on your architecture, so it can only be initialised with the memory address of a function.
So you could have something like the following...
void OnState1(uint8_t* readData, uint16_t sizeOfReadData)
{
...
}
stateMachineStep_s stateMachineSteps[3] = {
{STATE1, 10, 2, &OnState1}
...
}
which, to be honest, is not significantly more typing. You could also use macros to generate some of the code but that comes with it's own issues.
C++11 and greater support lambda expressions which will allow you to initialise your structs with a similar syntax to your example but in that case you would have to swap your function pointer to an std::function<> type. If you don't have c++11 support the boost library offers a similar function pointer but without the nicer lambda syntax.
modified 10-Jul-20 10:24am.
|
|
|
|
|
Josh Gray2 wrote: which, to be honest, is not significantly more typing It's not a matter of typing less, it's a matter of having code that is easy to read (I expect to have arount 50-60 states).Josh Gray2 wrote: If you don't have c++11 support the boost library offers a similar function pointer but without the nicer lambda syntax. When I googled it, it seems GCC has terrific support for C++.Josh Gray2 wrote: C++11 and greater support lambda expressions which will allow you to initialise your structs with a similar syntax to your example but in that case you would have to swap your function pointer to an std::function<> type. Could someone knowledgeable in C++ please help with the syntax for the example I provided? Do I need to put it inside a C++ file or it is possible have sections of a C-file containing C++ code?
|
|
|
|
|
arnold_w wrote: Could someone knowledgeable in C++ please help with the syntax for the example I provided? Do I need to put it inside a C++ file or it is possible have sections of a C-file containing C++ code? |
You can't put C++ code inside a C file, but since C++ is (mostly) a superset of C, most C code will compile without issue. About the only thing you can't do is use a C identifier that is a C++ keyword (e.g. int new; will not compile in C++).
Depending on what you're running on your ARM, you might be able to get C# (mono) up and running on your ARM device (e.g. raspberry pi or similar).
Keep Calm and Carry On
|
|
|
|
|
There is no syntax for your example, as neither C nor C++ have such a feature. A function pointer needs to contain the address of the function to be called.
|
|
|
|
|
If you are allowed to use (a modern version of) the C++ compiler (g++ ), then something like this
#include <functional>
#include <iostream>
using namespace std;
using MyCallback = function <void(const char * p, const size_t size)>;
struct State
{
int i;
MyCallback mc;
};
State s[] =
{
{ 10, [](const char * p, size_t size ){ for (size_t n=0; n<size; ++n) cout << p[n];}}
};
int main()
{
cout << s[0].i << endl;
s[0].mc( "foo", 3);
cout << endl;
}
would work.
|
|
|
|
|
I converted my project to a C++ project (I could see that the line <nature>org.eclipse.cdt.core.ccnature got added inside my .project file) and added your code, but I get the following error message when I try to build the project:
cannot open linker script file -Wl,-Map=output.map: No such file or directory MyProject C/C++ Problem
Do you know what I'm doing wrong?
|
|
|
|
|
|
So I went to Project Properties -> C/C++ Build -> Settings -> MCU G++ Linker and replaced the following Command line pattern:
${COMMAND} ${FLAGS} ${OUTPUT_FLAG} ${OUTPUT_PREFIX}${OUTPUT} ${INPUTS} with
arm-none-eabi-g++ -mcpu=cortex-m4 -mthumb -mfloat-abi=hard -mfpu=fpv4-sp-d16 -T"" -Wl,-Map,output.map -Wl,--gc-sections -fno-exceptions -fno-rtti -o "MyProject.elf" @"objects.list" -lm When I build the project and look inside the console window, I see the following:
Invoking: MCU G++ Linker
arm-none-eabi-g++ -mcpu=cortex-m4 -mthumb -mfloat-abi=hard -mfpu=fpv4-sp-d16 -T"" -Wl,-Map,output.map -Wl,--gc-sections -fno-exceptions -fno-rtti -o "MyProject.elf" @"objects.list" -lm -lm
c:/ac6/systemworkbench/plugins/fr.ac6.mcu.externaltools.arm-none.win32_1.17.0.201812190825/tools/compiler/bin/../lib/gcc/arm-none-eabi/7.3.1/../../../../arm-none-eabi/bin/ld.exe: cannot open linker script file -Wl,-Map,output.map: No such file or directory What did I do wrong?
|
|
|
|
|
arnold_w wrote: What did I do wrong? Nothing that I can see. I just did a build with -Wl,-Map,output.map and it worked fine. But the error message you have suggests that the linker is trying to read -Wl,-Map,output.map as a script file for some reason. I am not sure whether the MCU g++ linker is significantly different from the standard ld linker , but you may want to check the documentation.
|
|
|
|
|
It's probably a stupid question, but is there any way to make anonymous function usage like that compile inside a file with .c (not .cpp) extension? I know I'm allowed to put snippets of C-code inside a C++ file, but I suppose the opposite isn't possible (not even with clever macros)?
|
|
|
|
|
i'm just testing to run prog using parameters, but why i got error when debugging?
screenshot[^]
this is my code:
#include <iostream>
int main (int argc, char * argv []) {
if (argc > 0) {
std::cout << *argv[1] << std::endl;
}
std::cin.ignore(std::numeric_limits<int>::max(), '\n');
std::cout << "press ENTER to close program.";
std::cin.get();
return 0;
}
|
|
|
|
|
If you call the program via:
myprog.exe
then argc will equal 1 , and argv[1] will not exist, hence the exception. Remember, array indexes start from zero, not one.
|
|
|
|
|
i know, but how to respond users if there's argument(s) submitted?
|
|
|
|