# SDKERR\_WRONG\_USAGE using startRawRecording()

**URL:** <https://devforum.zoom.us/t/sdkerr-wrong-usage-using-startrawrecording/97800>\
**Category:** Windows\
**Created:** [November 3, 2023, 7:56am UTC](https://devforum.zoom.us/t/sdkerr-wrong-usage-using-startrawrecording/97800 "2023-11-03T07:56:44Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![filip.hunkevych](https://avatars.discourse-cdn.com/v4/letter/f/5f9b8f/32.png) [@filip.hunkevych](https://devforum.zoom.us/u/filip.hunkevych)\
**Post date:** [November 3, 2023, 7:56am UTC](https://devforum.zoom.us/t/sdkerr-wrong-usage-using-startrawrecording/97800/1 "2023-11-03T07:56:44Z")

</div>

**Description**  
After updating previous version of SDK with new one, I started to face exception when starting raw recoding.

**Which Windows Meeting SDK version?**  
Updating v5.13.1 to v5.13.5

**To Reproduce(If applicable)**  
When ZOOM\_SDK\_NAMESPACE::SDKError rtn = m\_pRecordController-\>StartRawRecording(); is invoked it returns SDKERR\_WRONG\_USAGE in zoom-sdk-windows\demo\sdk\_demo\_v2\CustomizedUIRecordMgr.cpp

It was working for my fine in previous version. Does it have something to do with newly added functions to IMeetingRecordingController?

New functions from the 3.15 SDK:

- virtual SDKError IsSupportRequestLocalRecordingPrivilege() = 0;
- virtual SDKError RequestLocalRecordingPrivilege() = 0;

I am using this function from 13.1 before starting raw recoding:

- onRecordPriviligeChanged

The code where error occurs:

```auto
void CustomizedUIRecordMgr::onRecordPriviligeChanged(bool bCanRec)
{
	if (g.zoomInfo.meeting.localRecordingToken.empty()) {
		dprintf("Start local recording attempted with empty token, ignored");
		return;
	}
	if (bCanRec) {
		//::MessageBox(NULL, _T("you can record now."), _T("winsdk demo"), MB_OK);
		dprintf_nsu("Calling StartRawRecording().\n");
		const auto now = system_clock::now();
		auto c_now = system_clock::to_time_t(now);
		StartRecording(c_now);
	} else {
		dprintf_nsu("Zoom cannot RAW record now.\n");
		//::MessageBox(NULL, _T("you can not record now."), _T("winsdk demo"), MB_OK);
	}
}

```

```auto
bool CustomizedUIRecordMgr::StartRecording(time_t& startTimestamp)
{
	GetRecordController();
	if (!m_pRecordController) {
		dprintf_nsu("m_pRecordController could not be acquired\n");
		return false;
	}

	ZOOM_SDK_NAMESPACE::SDKError rtn = m_pRecordController->StartRawRecording();
	if (rtn == ZOOM_SDK_NAMESPACE::SDKERR_SUCCESS) {
		dprintf_nsu("m_pRecordController->StartRawRecording() called.\n");
		return true;
	}

```

**Device (please complete the following information):**

- Device: AWS EC2 instance c5.xlarge
- OS: Windows Server 2019

---

<div class="post-metadata">

**Author:** ![filip.hunkevych](https://avatars.discourse-cdn.com/v4/letter/f/5f9b8f/32.png) [@filip.hunkevych](https://devforum.zoom.us/u/filip.hunkevych)\
**Post date:** [November 3, 2023, 7:53pm UTC](https://devforum.zoom.us/t/sdkerr-wrong-usage-using-startrawrecording/97800/2 "2023-11-03T19:53:28Z")

</div>

I am certainly sure I haven’t changed anything, just copied everything from /bin directory during debugging one more time, but now I am getting EXCEPTION ACCESS VIOLATION when app should perform shutdown. It occurs on calling DestroyMeetingService and refers to sdk.dll. I cannot debug dll files from /bin since there are no .pdb files (I guess this is normal state of things in the 3rd paty c++ desktop applications). Appreciate any help on this.

---

<div class="post-metadata">

**Author:** ![chunsiong.zoom](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/chunsiong.zoom/32/35488_2.png) [@chunsiong.zoom](https://devforum.zoom.us/u/chunsiong.zoom)\
**Post date:** [November 6, 2023, 5:23am UTC](https://devforum.zoom.us/t/sdkerr-wrong-usage-using-startrawrecording/97800/3 "2023-11-06T05:23:57Z")

</div>

@filip.hunkevych I’m on 5.16.x but these flow should apply.

1. When the bot is in inmeeting status, check `CanIStartLocalRecording`  
1.1 If bot doesn’t have permission yet, request for permission via `m_pRecordController->RequestLocalRecordingPrivilege();`  
Use the callback `onCoHostChangeNotification` , `onHostChangeNotification` or `onRecordPrivilegeChanged` to check if Host has given the bot permission for recording. Assuming the host did give the bot permission, Go to Step 2.  
1.2 If bot already has permission, Go to Step 2.

2.`attemptToStartRawRecording` by calling StartRawRecording.

```auto
void attemptToStartRawRecording() {

	m_pRecordController = meetingService->GetMeetingRecordingController();

	SDKError err1 = m_pRecordController->StartRawRecording();
	if (err1 != SDKERR_SUCCESS) {
		std::cout << "Error occurred";
	}

	SDKError err = createRenderer(&videoHelper, videoSource);
	if (err != SDKERR_SUCCESS) {
		std::cout << "Error occurred";
		//handle error
	}
	else {
		videoHelper->setRawDataResolution(ZoomSDKResolution_720P);
		videoHelper->subscribe(getUserID(), RAW_DATA_TYPE_VIDEO);
	}

}

bool CanIStartLocalRecording()
{
	
	IMeetingRecordingController* m_pRecordController = meetingService->GetMeetingRecordingController();
	if (m_pRecordController)
	{

		SDKError err = m_pRecordController->CanStartRecording(false, 0); //0 refers to current user
		if (err != SDKERR_SUCCESS) {
			std::cout << "Cannot start local recording...\n";

			std::cout << "Requesting...\n";
			m_pRecordController->RequestLocalRecordingPrivilege();
			//handle error
			return false;
		}
		else {
			std::cout << "Can start local recording...\n";
			return true;
		}

	}
}

```

---

<div class="post-metadata">

**Author:** ![philip2](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/philip2/32/53130_2.png) [@philip2](https://devforum.zoom.us/u/philip2)\
**Post date:** [November 6, 2023, 12:55pm UTC](https://devforum.zoom.us/t/sdkerr-wrong-usage-using-startrawrecording/97800/4 "2023-11-06T12:55:50Z")

</div>

Thank you so much. [Chun Siong](https://devforum.zoom.us/u/chunsiong.zoom). Could you also help me figure out possible reasons for exception access violation when zoom sdk is performing CleanUp? Specifically when calling DestroyMeetingService() in sdk\_util.cpp. Exception refers to sdk.dll and that is everything I have.

I can see similar thread with no answer [CleanUpSDK leads to eventual crash](https://devforum.zoom.us/t/cleanupsdk-leads-to-eventual-crash/71492)

---

<div class="post-metadata">

**Author:** ![chunsiong.zoom](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/chunsiong.zoom/32/35488_2.png) [@chunsiong.zoom](https://devforum.zoom.us/u/chunsiong.zoom)\
**Post date:** [November 7, 2023, 7:52am UTC](https://devforum.zoom.us/t/sdkerr-wrong-usage-using-startrawrecording/97800/5 "2023-11-07T07:52:13Z")

</div>

@philip2 ,

I’m doing this, and have no issues calling cleanup.  
This cleanup is invoked when the meeting ends.

```auto
void cleanup() {
	if (meetingService) DestroyMeetingService(meetingService);
	if (authService) DestroyAuthService(authService);
	if (network_connection_helper) DestroyNetworkConnectionHelper(network_connection_helper);
	CleanUPSDK(); // must do this, or it will crash. 
}
/// <summary>
/// main method for entry point
/// </summary>
/// <returns></returns>
int main()
{
	LoadConfig();
	InitSDK();

	int bRet = false;
	MSG msg;
	while (!g_exit && (bRet = GetMessage(&msg, nullptr, 0, 0)) != 0)
	{
		if (bRet == -1)
		{
			// handle the error and possibly exit
		}
		else
		{
			TranslateMessage(&msg);
			DispatchMessage(&msg);
		}
	}
	cleanup();
	return 0;
}

```

---

<div class="post-metadata">

**Author:** ![filip.hunkevych](https://avatars.discourse-cdn.com/v4/letter/f/5f9b8f/32.png) [@filip.hunkevych](https://devforum.zoom.us/u/filip.hunkevych)\
**Post date:** [November 8, 2023, 9:51am UTC](https://devforum.zoom.us/t/sdkerr-wrong-usage-using-startrawrecording/97800/6 "2023-11-08T09:51:39Z")

</div>

@chunsiong.zoom thank you for showing me that minimalistic example is working (I didn’t have doubts about this), but just to give more context: I updated zoom from 13.1 to 13.5. I am using zoom sdk as it is (demo code) with a couple of tweeks. In 13.5 it throws exceptions either when destroying meeting service or on CleanUPSDK (if destroy meeting service is commented out). Since no files that related to creating meeting service and destroying meeting service were changed in 13.5 comparing to 13.1, it looks odd. Also, changelog of 13.5 doesn’t include any mentions regarding creating or destroying meeting service. Though, in this version it started to break. Is there any info on what exactly needs to be initialized in meeting service in order for it to be destroyed correctly? Maybe, some method that needs to be callled before destroying meeting service?

---

<div class="post-metadata">

**Author:** ![filip.hunkevych](https://avatars.discourse-cdn.com/v4/letter/f/5f9b8f/32.png) [@filip.hunkevych](https://devforum.zoom.us/u/filip.hunkevych)\
**Post date:** [November 8, 2023, 10:24am UTC](https://devforum.zoom.us/t/sdkerr-wrong-usage-using-startrawrecording/97800/7 "2023-11-08T10:24:31Z")

</div>

```auto
ZOOM_SDK_NAMESPACE::IMeetingService* _meeting_service;

ZOOM_SDK_NAMESPACE::IMeetingService* SDKInterfaceWrap::GetMeetingService()
{
	if (_inited && NULL == _meeting_service)
	{
		ZOOM_SDK_NAMESPACE::SDKError meetingServiceInitReturnVal = ZOOM_SDK_NAMESPACE::CreateMeetingService(&_meeting_service);
		if (meetingServiceInitReturnVal != ZOOM_SDK_NAMESPACE::SDKERR_SUCCESS) {
			dprintf_nsu("failed to initialize meeting service\n");
		} else {
			_meeting_service->SetEvent(this);
			GetMeetingParticipantsController();
			GetMeetingChatController();
		}
	}

	return _meeting_service;
}

ZOOM_SDK_NAMESPACE::SDKError SDKInterfaceWrap::Cleanup()
{
	if (_inited)
	{
		_customiezed_ui_mode = false;
		if (_auth_service)
		{
			ZOOM_SDK_NAMESPACE::DestroyAuthService(_auth_service);
			_auth_service = NULL;
		}

		if(_setting_service)
		{
			ZOOM_SDK_NAMESPACE::DestroySettingService(_setting_service);
			_setting_service = NULL;
		}

		if (_meeting_service)
		{
			ZOOM_SDK_NAMESPACE::DestroyMeetingService(_meeting_service); // here's the exception
			_meeting_service = NULL;
		}

		if (_network_connection_helper)
		{
			ZOOM_SDK_NAMESPACE::DestroyNetworkConnectionHelper(_network_connection_helper);
			_network_connection_helper = NULL;
		}
		
		if (_last_error)
		{
			_last_error = NULL;
		}
	
		ZOOM_SDK_NAMESPACE::CleanUPSDK();

		_inited = false;
		return ZOOM_SDK_NAMESPACE::SDKERR_SUCCESS;
	}
	return ZOOM_SDK_NAMESPACE::SDKERR_WRONG_USAGE;
}

```

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex016/uploads/zoomdeveloper/original/3X/6/1/614bdd549b610bbaa46ff934617683a02bdaa03c.png) [@system](https://devforum.zoom.us/u/system)\
**Post date:** [December 9, 2023, 1:46am UTC](https://devforum.zoom.us/t/sdkerr-wrong-usage-using-startrawrecording/97800/9 "2023-12-09T01:46:26Z")

</div>

Closed on December 9, 2023, 1:46am UTC

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.
