Skip to content

Commit ad67e02

Browse files
Copilotwysaid
andcommitted
Complete API optimization - remove legacy functions completely
Co-authored-by: wysaid <1430725+wysaid@users.noreply.github.com>
1 parent 7c44b74 commit ad67e02

2 files changed

Lines changed: 1 addition & 69 deletions

File tree

include/ccap_c.h

Lines changed: 1 addition & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -148,31 +148,13 @@ void ccap_provider_destroy(CcapProvider* provider);
148148
/* ========== Device Discovery ========== */
149149

150150
/**
151-
* @brief Find all available camera device names (new optimized API)
151+
* @brief Find all available camera device names
152152
* @param provider Pointer to CcapProvider instance
153153
* @param deviceList Output parameter for device names list
154154
* @return true on success, false on failure
155155
*/
156156
bool ccap_provider_find_device_names_list(CcapProvider* provider, CcapDeviceNamesList* deviceList);
157157

158-
/**
159-
* @brief Find all available camera device names (legacy API - deprecated)
160-
* @param provider Pointer to CcapProvider instance
161-
* @param deviceNames Output array of device name strings (caller must free each string and the array)
162-
* @param count Output parameter for number of devices found
163-
* @return true on success, false on failure
164-
* @deprecated Use ccap_provider_find_device_names_list instead
165-
*/
166-
bool ccap_provider_find_device_names(CcapProvider* provider, char*** deviceNames, size_t* count);
167-
168-
/**
169-
* @brief Free device names array returned by ccap_provider_find_device_names (legacy API - deprecated)
170-
* @param deviceNames Array of device name strings
171-
* @param count Number of device names
172-
* @deprecated Use ccap_provider_find_device_names_list instead
173-
*/
174-
void ccap_provider_free_device_names(char** deviceNames, size_t count);
175-
176158
/* ========== Device Management ========== */
177159

178160
/**

src/ccap_c.cpp

Lines changed: 0 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -47,16 +47,6 @@ CcapFrameOrientation convert_frame_orientation_to_c(ccap::FrameOrientation orien
4747
return static_cast<CcapFrameOrientation>(static_cast<uint32_t>(orientation));
4848
}
4949

50-
// Helper to allocate and copy C string
51-
char* allocate_c_string(const std::string& str) {
52-
if (str.empty()) return nullptr;
53-
char* result = static_cast<char*>(malloc(str.length() + 1));
54-
if (result) {
55-
strcpy(result, str.c_str());
56-
}
57-
return result;
58-
}
59-
6050
// Wrapper struct for callback management
6151
struct CallbackWrapper {
6252
CcapNewFrameCallback callback;
@@ -131,46 +121,6 @@ bool ccap_provider_find_device_names_list(CcapProvider* provider, CcapDeviceName
131121
return true;
132122
}
133123

134-
bool ccap_provider_find_device_names(CcapProvider* provider, char*** deviceNames, size_t* count) {
135-
if (!provider || !deviceNames || !count) return false;
136-
137-
auto* cppProvider = reinterpret_cast<ccap::Provider*>(provider);
138-
auto devices = cppProvider->findDeviceNames();
139-
140-
*count = devices.size();
141-
if (*count == 0) {
142-
*deviceNames = nullptr;
143-
return true;
144-
}
145-
146-
char** names = static_cast<char**>(malloc(*count * sizeof(char*)));
147-
if (!names) return false;
148-
149-
for (size_t i = 0; i < *count; ++i) {
150-
names[i] = allocate_c_string(devices[i]);
151-
if (!names[i]) {
152-
// Cleanup on failure
153-
for (size_t j = 0; j < i; ++j) {
154-
free(names[j]);
155-
}
156-
free(names);
157-
return false;
158-
}
159-
}
160-
161-
*deviceNames = names;
162-
return true;
163-
}
164-
165-
void ccap_provider_free_device_names(char** deviceNames, size_t count) {
166-
if (deviceNames) {
167-
for (size_t i = 0; i < count; ++i) {
168-
free(deviceNames[i]);
169-
}
170-
free(deviceNames);
171-
}
172-
}
173-
174124
/* ========== Device Management ========== */
175125

176126
bool ccap_provider_open(CcapProvider* provider, const char* deviceName, bool autoStart) {

0 commit comments

Comments
 (0)