-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Val: Un-mocking the TestApp with actual API-based implementation (#308)
* sdk succesfully linked to TestApp Signed-off-by: Lukas G <[email protected]> Signed-off-by: Mateusz Grabuszyński <[email protected]>
- Loading branch information
Showing
13 changed files
with
311 additions
and
377 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
set noparent | ||
exclude_files=tests |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,12 @@ | ||
/* | ||
* SPDX-FileCopyrightText: Copyright (c) 2025 Intel Corporation | ||
* | ||
* SPDX-License-Identifier: BSD-3-Clause | ||
*/ | ||
|
||
#ifndef _INPUT_H_ | ||
#define _INPUT_H_ | ||
|
||
const char* parse_json_to_string(const char* file_name); | ||
int is_mock_enabled(); | ||
|
||
char *parse_json_to_string(const char *file_name); | ||
|
||
#endif /* _INPUT_H_*/ | ||
#endif /* _INPUT_H_ */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,21 @@ | ||
|
||
/* | ||
* SPDX-FileCopyrightText: Copyright (c) 2025 Intel Corporation | ||
* | ||
* SPDX-License-Identifier: BSD-3-Clause | ||
*/ | ||
|
||
#ifndef _MCM_H_ | ||
#define _MCM_H_ | ||
#include "mcm_mock.h" | ||
|
||
#define DUMMY_LEN 1 | ||
typedef struct mcm_ts{ | ||
MeshConnection *connection; | ||
MeshClient *client; | ||
}mcm_ts; | ||
|
||
#include <stdio.h> | ||
#include "mesh_dp.h" | ||
|
||
int mcm_init_client(mcm_ts* mcm, const char* cfg); | ||
int mcm_create_tx_connection(mcm_ts* mcm, const char* cfg); | ||
int mcm_create_rx_connection(mcm_ts* mcm, const char* cfg); | ||
int mcm_send_video_frame(mcm_ts* mcm, const char* frame, int frame_len); | ||
int mcm_receive_video_frames(mcm_ts* mcm); | ||
int file_to_buffer(FILE* fp, MeshBuffer* buf, int frame_size); | ||
int mcm_init_client(MeshConnection **connection, MeshClient *client, const char *cfg); | ||
int mcm_create_tx_connection(MeshConnection *connection, MeshClient *client, const char *cfg); | ||
int mcm_create_rx_connection(MeshConnection *connection, MeshClient *client, const char *cfg); | ||
int mcm_send_video_frames(MeshConnection *connection, const char *filename); | ||
void read_data_in_loop(MeshConnection *connection, const char *filename); | ||
int is_root(); | ||
|
||
#endif /* _MCM_H_*/ | ||
#endif /* _MCM_H_ */ |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,36 +1,46 @@ | ||
# TestApp | ||
|
||
Application for utilizing MCM api, | ||
Application for utilizing Media Communications Mesh SDK API. | ||
|
||
*Disclaimer* | ||
TX/RXapp is prepared for new api (/docs/sdk-json-proposal) that is not implemented yet, so, so far it works with simple mocks, that move a file from TxApp to RxApp. | ||
## Prerequisities | ||
before building this code following libreries need to be build and installed on host system: | ||
* [grpc](grpcMedia-Communications-Mesh/sdk/README.md) | ||
* [memif](Media-Communications-Mesh/sdk/3rdparty/libmemif/docs/buildinstructions_doc.rst) | ||
|
||
test apps use them as shared libraries during linking stage, without them, compilation will fail. | ||
|
||
## Usage | ||
1. Create directory: | ||
```shell | ||
mkdir /tmp/MCM_MOCK | ||
``` | ||
1. Build binaries: | ||
```shell | ||
mkdir build && cd build | ||
cmake .. | ||
make | ||
touch client.json | ||
touch connection.json | ||
``` | ||
```shell | ||
mkdir build && cd build | ||
cmake .. | ||
make | ||
``` | ||
|
||
1. Run RxApp: | ||
```shell | ||
$ ./RxApp | ||
launching RX App | ||
RX App PID: 956656 | ||
reading client configuration... | ||
reading connection configuration... | ||
waiting for frames.. | ||
2. Prepare client and conneciton files for sender (TxApp) and receiver (RxApp) | ||
```shell | ||
touch client_tx.json | ||
touch connection_tx.json | ||
touch client_rx.json | ||
touch connection_rx.json | ||
``` | ||
> Note: The names of the files can differ from the ones presented above, but they must be reflected in the commands as in the following points. | ||
Exemplary contents of those files can be found in [`client_example.json`](client_example.json) and [`connection_example.json`](connection_example.json). For more, check [appropriate documentation](../../../docs/sdk-json-proposal/SDK_API_WORKFLOW.md). | ||
|
||
``` | ||
3. Run RxApp: | ||
```shell | ||
./RxApp <client_cfg.json> <connection_cfg.json> <path_to_output_file> | ||
``` | ||
For example: | ||
```shell | ||
./RxApp client_rx.json connection_rx.json output_video.yuv | ||
``` | ||
|
||
1. Run TxApp: | ||
```shell | ||
./TxApp <abs path to file to transmit> <RX App PID> | ||
``` | ||
4. Run TxApp: | ||
```shell | ||
./TxApp <client_cfg.json> <connection_cfg.json> <path_to_input_file> | ||
``` | ||
For example: | ||
```shell | ||
./RxApp client_tx.json connection_tx.json input_video.yuv | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"apiVersion": "v1", | ||
"apiConnectionString": "Server=127.0.0.1; Port=8002", | ||
"apiDefaultTimeoutMicroseconds": 100000, | ||
"maxMediaConnections": 32 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
{ | ||
"connection": { | ||
"multipointGroup": { | ||
"urn": "ipv4:192.168.123.123" | ||
} | ||
}, | ||
"payload": { | ||
"video": { | ||
"width": 1920, | ||
"height": 1080, | ||
"fps": 60.0, | ||
"pixelFormat": "yuv422p10rfc4175" | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,59 @@ | ||
#include <stdio.h> | ||
#include <unistd.h> | ||
#include <stdlib.h> | ||
#include "Inc/input.h" | ||
#include "Inc/mcm.h" | ||
#include <unistd.h> | ||
|
||
const char* client_cfg; | ||
const char* conn_cfg; | ||
|
||
int main(int argc, char* argv[]){ | ||
|
||
printf("launching RX App \n"); | ||
printf("RX App PID: %d\n", getpid()); | ||
printf("reading client configuration... \n"); | ||
client_cfg = parse_json_to_string("client.json"); | ||
printf("reading connection configuration... \n"); | ||
conn_cfg = parse_json_to_string("connection.json"); | ||
mcm_ts mcm; | ||
mcm_init_client(&mcm, client_cfg); | ||
mcm_create_rx_connection(&mcm, conn_cfg); | ||
printf("waiting for frames... \n"); | ||
while(1){ | ||
// mcm_create_rx_connection(&mcm, conn_cfg); | ||
// mcm_receive_video_frames(&mcm); | ||
} | ||
return 0; | ||
} | ||
char *client_cfg; | ||
char *conn_cfg; | ||
|
||
int main(int argc, char *argv[]) { | ||
if (!is_root()) { | ||
fprintf(stderr, "This program must be run as root. Exiting.\n"); | ||
exit(EXIT_FAILURE); | ||
} | ||
if (argc != 4) { | ||
fprintf(stderr, "Usage: %s <client_cfg.json> <connection_cfg.json> <path_to_output_file>\n", | ||
argv[0]); | ||
exit(EXIT_FAILURE); | ||
} | ||
|
||
char *client_cfg_file = argv[1]; | ||
char *conn_cfg_file = argv[2]; | ||
char *out_filename = argv[3]; | ||
|
||
MeshConnection *connection = NULL; | ||
MeshClient *client = NULL; | ||
|
||
printf("[RX] Launching RX App \n"); | ||
printf("[RX] Reading client configuration... \n"); | ||
client_cfg = parse_json_to_string(client_cfg_file); | ||
printf("[RX] Reading connection configuration... \n"); | ||
conn_cfg = parse_json_to_string(conn_cfg_file); | ||
|
||
/* Initialize mcm client */ | ||
int err = mesh_create_client_json(&client, client_cfg); | ||
if (err) { | ||
printf("[RX] Failed to create mesh client: %s (%d)\n", mesh_err2str(err), err); | ||
goto safe_exit; | ||
} | ||
|
||
/* Create mesh connection */ | ||
err = mesh_create_rx_connection(client, &connection, conn_cfg); | ||
if (err) { | ||
printf("[RX] Failed to create connection: %s (%d)\n", mesh_err2str(err), err); | ||
mesh_delete_client(&client); | ||
goto safe_exit; | ||
} | ||
printf("[RX] Waiting for frames... \n"); | ||
read_data_in_loop(connection, out_filename); | ||
printf("[RX] Shuting down connection and client\n"); | ||
mesh_delete_connection(&connection); | ||
mesh_delete_client(&client); | ||
printf("[RX] Shutdown completed exiting\n"); | ||
|
||
safe_exit: | ||
free(client_cfg); | ||
free(conn_cfg); | ||
return err; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.