1 #include "include/dvr/dvr_configuration_data.h"
2 
3 #include <private/dvr/display_client.h>
4 
5 using android::dvr::display::ConfigFileType;
6 using android::dvr::display::DisplayClient;
7 
8 extern "C" {
9 
dvrConfigurationDataGet(int config_type,uint8_t ** data,size_t * data_size)10 int dvrConfigurationDataGet(int config_type, uint8_t** data,
11                             size_t* data_size) {
12   if (!data || !data_size) {
13     return -EINVAL;
14   }
15 
16   auto client = DisplayClient::Create();
17   if (!client) {
18     ALOGE("dvrGetGlobalBuffer: Failed to create display client!");
19     return -ECOMM;
20   }
21 
22   ConfigFileType config_file_type = static_cast<ConfigFileType>(config_type);
23   auto config_data_status =
24       client->GetConfigurationData(config_file_type);
25 
26   if (!config_data_status) {
27     return -config_data_status.error();
28   }
29 
30   *data_size = config_data_status.get().size();
31   *data = new uint8_t[*data_size];
32   std::copy_n(config_data_status.get().begin(), *data_size, *data);
33   return 0;
34 }
35 
dvrConfigurationDataDestroy(uint8_t * data)36 void dvrConfigurationDataDestroy(uint8_t* data) {
37   delete[] data;
38 }
39 
40 }  // extern "C"
41