| 
						
						
							
								
							
						
						
					 | 
					 | 
					@ -34,8 +34,7 @@ extern ExitHandler do_exit; | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					// ***** OMX callback functions *****
 | 
					 | 
					 | 
					 | 
					// ***** OMX callback functions *****
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					void OmxEncoder::set_state_blocking(OMX_STATETYPE state) { | 
					 | 
					 | 
					 | 
					void OmxEncoder::wait_for_state(OMX_STATETYPE state) { | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					  OMX_CHECK(OMX_SendCommand(this->handle, OMX_CommandStateSet, state, NULL)); | 
					 | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					  pthread_mutex_lock(&this->state_lock); | 
					 | 
					 | 
					 | 
					  pthread_mutex_lock(&this->state_lock); | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					  while (this->state != state) { | 
					 | 
					 | 
					 | 
					  while (this->state != state) { | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    pthread_cond_wait(&this->state_cv, &this->state_lock); | 
					 | 
					 | 
					 | 
					    pthread_cond_wait(&this->state_cv, &this->state_lock); | 
				
			
			
		
	
	
		
		
			
				
					| 
						
							
								
							
						
						
							
								
							
						
						
					 | 
					 | 
					@ -305,7 +304,7 @@ OmxEncoder::OmxEncoder(const char* filename, int width, int height, int fps, int | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					  //   printf("profile %d level 0x%x\n", params.eProfile, params.eLevel);
 | 
					 | 
					 | 
					 | 
					  //   printf("profile %d level 0x%x\n", params.eProfile, params.eLevel);
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					  // }
 | 
					 | 
					 | 
					 | 
					  // }
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					  set_state_blocking(OMX_StateIdle); | 
					 | 
					 | 
					 | 
					  OMX_CHECK(OMX_SendCommand(this->handle, OMX_CommandStateSet, OMX_StateIdle, NULL)); | 
				
			
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					  for (auto &buf : this->in_buf_headers) { | 
					 | 
					 | 
					 | 
					  for (auto &buf : this->in_buf_headers) { | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    OMX_CHECK(OMX_AllocateBuffer(this->handle, &buf, PORT_INDEX_IN, this, | 
					 | 
					 | 
					 | 
					    OMX_CHECK(OMX_AllocateBuffer(this->handle, &buf, PORT_INDEX_IN, this, | 
				
			
			
		
	
	
		
		
			
				
					| 
						
						
						
							
								
							
						
					 | 
					 | 
					@ -317,7 +316,11 @@ OmxEncoder::OmxEncoder(const char* filename, int width, int height, int fps, int | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					                             out_port.nBufferSize)); | 
					 | 
					 | 
					 | 
					                             out_port.nBufferSize)); | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					  } | 
					 | 
					 | 
					 | 
					  } | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					  set_state_blocking(OMX_StateExecuting); | 
					 | 
					 | 
					 | 
					  wait_for_state(OMX_StateIdle); | 
				
			
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					  OMX_CHECK(OMX_SendCommand(this->handle, OMX_CommandStateSet, OMX_StateExecuting, NULL)); | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					  wait_for_state(OMX_StateExecuting); | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					  // give omx all the output buffers
 | 
					 | 
					 | 
					 | 
					  // give omx all the output buffers
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					  for (auto &buf : this->out_buf_headers) { | 
					 | 
					 | 
					 | 
					  for (auto &buf : this->out_buf_headers) { | 
				
			
			
		
	
	
		
		
			
				
					| 
						
							
								
							
						
						
							
								
							
						
						
					 | 
					 | 
					@ -590,8 +593,11 @@ void OmxEncoder::encoder_close() { | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					OmxEncoder::~OmxEncoder() { | 
					 | 
					 | 
					 | 
					OmxEncoder::~OmxEncoder() { | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					  assert(!this->is_open); | 
					 | 
					 | 
					 | 
					  assert(!this->is_open); | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					  set_state_blocking(OMX_StateIdle); | 
					 | 
					 | 
					 | 
					  OMX_CHECK(OMX_SendCommand(this->handle, OMX_CommandStateSet, OMX_StateIdle, NULL)); | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					  set_state_blocking(OMX_StateLoaded); | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
				
				
			
		
	
		
		
	
		
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					  wait_for_state(OMX_StateIdle); | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					  OMX_CHECK(OMX_SendCommand(this->handle, OMX_CommandStateSet, OMX_StateLoaded, NULL)); | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					  for (auto &buf : this->in_buf_headers) { | 
					 | 
					 | 
					 | 
					  for (auto &buf : this->in_buf_headers) { | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    OMX_CHECK(OMX_FreeBuffer(this->handle, PORT_INDEX_IN, buf)); | 
					 | 
					 | 
					 | 
					    OMX_CHECK(OMX_FreeBuffer(this->handle, PORT_INDEX_IN, buf)); | 
				
			
			
		
	
	
		
		
			
				
					| 
						
						
						
							
								
							
						
					 | 
					 | 
					@ -601,6 +607,8 @@ OmxEncoder::~OmxEncoder() { | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    OMX_CHECK(OMX_FreeBuffer(this->handle, PORT_INDEX_OUT, buf)); | 
					 | 
					 | 
					 | 
					    OMX_CHECK(OMX_FreeBuffer(this->handle, PORT_INDEX_OUT, buf)); | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					  } | 
					 | 
					 | 
					 | 
					  } | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					  wait_for_state(OMX_StateLoaded); | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					  OMX_CHECK(OMX_FreeHandle(this->handle)); | 
					 | 
					 | 
					 | 
					  OMX_CHECK(OMX_FreeHandle(this->handle)); | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					  OMX_BUFFERHEADERTYPE *out_buf; | 
					 | 
					 | 
					 | 
					  OMX_BUFFERHEADERTYPE *out_buf; | 
				
			
			
		
	
	
		
		
			
				
					| 
						
							
								
							
						
						
						
					 | 
					 | 
					
  |