| OLD | NEW | 
|---|
| 1 /* | 1 /* | 
| 2  * libjingle | 2  * libjingle | 
| 3  * Copyright 2015 Google Inc. | 3  * Copyright 2015 Google Inc. | 
| 4  * | 4  * | 
| 5  * Redistribution and use in source and binary forms, with or without | 5  * Redistribution and use in source and binary forms, with or without | 
| 6  * modification, are permitted provided that the following conditions are met: | 6  * modification, are permitted provided that the following conditions are met: | 
| 7  * | 7  * | 
| 8  *  1. Redistributions of source code must retain the above copyright notice, | 8  *  1. Redistributions of source code must retain the above copyright notice, | 
| 9  *     this list of conditions and the following disclaimer. | 9  *     this list of conditions and the following disclaimer. | 
| 10  *  2. Redistributions in binary form must reproduce the above copyright notice, | 10  *  2. Redistributions in binary form must reproduce the above copyright notice, | 
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 43 class AndroidVideoCapturer::FrameFactory : public cricket::VideoFrameFactory { | 43 class AndroidVideoCapturer::FrameFactory : public cricket::VideoFrameFactory { | 
| 44  public: | 44  public: | 
| 45   FrameFactory(const rtc::scoped_refptr<AndroidVideoCapturerDelegate>& delegate) | 45   FrameFactory(const rtc::scoped_refptr<AndroidVideoCapturerDelegate>& delegate) | 
| 46       : delegate_(delegate) { | 46       : delegate_(delegate) { | 
| 47     // Create a CapturedFrame that only contains header information, not the | 47     // Create a CapturedFrame that only contains header information, not the | 
| 48     // actual pixel data. | 48     // actual pixel data. | 
| 49     captured_frame_.pixel_height = 1; | 49     captured_frame_.pixel_height = 1; | 
| 50     captured_frame_.pixel_width = 1; | 50     captured_frame_.pixel_width = 1; | 
| 51     captured_frame_.data = nullptr; | 51     captured_frame_.data = nullptr; | 
| 52     captured_frame_.data_size = cricket::CapturedFrame::kUnknownDataSize; | 52     captured_frame_.data_size = cricket::CapturedFrame::kUnknownDataSize; | 
| 53     captured_frame_.fourcc = static_cast<uint32>(cricket::FOURCC_ANY); | 53     captured_frame_.fourcc = static_cast<uint32_t>(cricket::FOURCC_ANY); | 
| 54   } | 54   } | 
| 55 | 55 | 
| 56   void UpdateCapturedFrame( | 56   void UpdateCapturedFrame( | 
| 57       const rtc::scoped_refptr<webrtc::VideoFrameBuffer>& buffer, | 57       const rtc::scoped_refptr<webrtc::VideoFrameBuffer>& buffer, | 
| 58       int rotation, | 58       int rotation, | 
| 59       int64 time_stamp_in_ns) { | 59       int64_t time_stamp_in_ns) { | 
| 60     buffer_ = buffer; | 60     buffer_ = buffer; | 
| 61     captured_frame_.width = buffer->width(); | 61     captured_frame_.width = buffer->width(); | 
| 62     captured_frame_.height = buffer->height(); | 62     captured_frame_.height = buffer->height(); | 
| 63     captured_frame_.time_stamp = time_stamp_in_ns; | 63     captured_frame_.time_stamp = time_stamp_in_ns; | 
| 64     captured_frame_.rotation = rotation; | 64     captured_frame_.rotation = rotation; | 
| 65   } | 65   } | 
| 66 | 66 | 
| 67   void ClearCapturedFrame() { | 67   void ClearCapturedFrame() { | 
| 68     buffer_ = nullptr; | 68     buffer_ = nullptr; | 
| 69     captured_frame_.width = 0; | 69     captured_frame_.width = 0; | 
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 162   delegate_->Stop(); | 162   delegate_->Stop(); | 
| 163   current_state_ = cricket::CS_STOPPED; | 163   current_state_ = cricket::CS_STOPPED; | 
| 164   SignalStateChange(this, current_state_); | 164   SignalStateChange(this, current_state_); | 
| 165 } | 165 } | 
| 166 | 166 | 
| 167 bool AndroidVideoCapturer::IsRunning() { | 167 bool AndroidVideoCapturer::IsRunning() { | 
| 168   RTC_CHECK(thread_checker_.CalledOnValidThread()); | 168   RTC_CHECK(thread_checker_.CalledOnValidThread()); | 
| 169   return running_; | 169   return running_; | 
| 170 } | 170 } | 
| 171 | 171 | 
| 172 bool AndroidVideoCapturer::GetPreferredFourccs(std::vector<uint32>* fourccs) { | 172 bool AndroidVideoCapturer::GetPreferredFourccs(std::vector<uint32_t>* fourccs) { | 
| 173   RTC_CHECK(thread_checker_.CalledOnValidThread()); | 173   RTC_CHECK(thread_checker_.CalledOnValidThread()); | 
| 174   fourccs->push_back(cricket::FOURCC_YV12); | 174   fourccs->push_back(cricket::FOURCC_YV12); | 
| 175   return true; | 175   return true; | 
| 176 } | 176 } | 
| 177 | 177 | 
| 178 void AndroidVideoCapturer::OnCapturerStarted(bool success) { | 178 void AndroidVideoCapturer::OnCapturerStarted(bool success) { | 
| 179   RTC_CHECK(thread_checker_.CalledOnValidThread()); | 179   RTC_CHECK(thread_checker_.CalledOnValidThread()); | 
| 180   cricket::CaptureState new_state = | 180   cricket::CaptureState new_state = | 
| 181       success ? cricket::CS_RUNNING : cricket::CS_FAILED; | 181       success ? cricket::CS_RUNNING : cricket::CS_FAILED; | 
| 182   if (new_state == current_state_) | 182   if (new_state == current_state_) | 
| 183     return; | 183     return; | 
| 184   current_state_ = new_state; | 184   current_state_ = new_state; | 
| 185 | 185 | 
| 186   // TODO(perkj): SetCaptureState can not be used since it posts to |thread_|. | 186   // TODO(perkj): SetCaptureState can not be used since it posts to |thread_|. | 
| 187   // But |thread_ | is currently just the thread that happened to create the | 187   // But |thread_ | is currently just the thread that happened to create the | 
| 188   // cricket::VideoCapturer. | 188   // cricket::VideoCapturer. | 
| 189   SignalStateChange(this, new_state); | 189   SignalStateChange(this, new_state); | 
| 190 } | 190 } | 
| 191 | 191 | 
| 192 void AndroidVideoCapturer::OnIncomingFrame( | 192 void AndroidVideoCapturer::OnIncomingFrame( | 
| 193     rtc::scoped_refptr<webrtc::VideoFrameBuffer> buffer, | 193     rtc::scoped_refptr<webrtc::VideoFrameBuffer> buffer, | 
| 194     int rotation, | 194     int rotation, | 
| 195     int64 time_stamp) { | 195     int64_t time_stamp) { | 
| 196   RTC_CHECK(thread_checker_.CalledOnValidThread()); | 196   RTC_CHECK(thread_checker_.CalledOnValidThread()); | 
| 197   frame_factory_->UpdateCapturedFrame(buffer, rotation, time_stamp); | 197   frame_factory_->UpdateCapturedFrame(buffer, rotation, time_stamp); | 
| 198   SignalFrameCaptured(this, frame_factory_->GetCapturedFrame()); | 198   SignalFrameCaptured(this, frame_factory_->GetCapturedFrame()); | 
| 199   frame_factory_->ClearCapturedFrame(); | 199   frame_factory_->ClearCapturedFrame(); | 
| 200 } | 200 } | 
| 201 | 201 | 
| 202 void AndroidVideoCapturer::OnOutputFormatRequest( | 202 void AndroidVideoCapturer::OnOutputFormatRequest( | 
| 203     int width, int height, int fps) { | 203     int width, int height, int fps) { | 
| 204   RTC_CHECK(thread_checker_.CalledOnValidThread()); | 204   RTC_CHECK(thread_checker_.CalledOnValidThread()); | 
| 205   const cricket::VideoFormat& current = video_adapter()->output_format(); | 205   const cricket::VideoFormat& current = video_adapter()->output_format(); | 
| 206   cricket::VideoFormat format( | 206   cricket::VideoFormat format( | 
| 207       width, height, cricket::VideoFormat::FpsToInterval(fps), current.fourcc); | 207       width, height, cricket::VideoFormat::FpsToInterval(fps), current.fourcc); | 
| 208   video_adapter()->OnOutputFormatRequest(format); | 208   video_adapter()->OnOutputFormatRequest(format); | 
| 209 } | 209 } | 
| 210 | 210 | 
| 211 bool AndroidVideoCapturer::GetBestCaptureFormat( | 211 bool AndroidVideoCapturer::GetBestCaptureFormat( | 
| 212     const cricket::VideoFormat& desired, | 212     const cricket::VideoFormat& desired, | 
| 213     cricket::VideoFormat* best_format) { | 213     cricket::VideoFormat* best_format) { | 
| 214   // Delegate this choice to VideoCapturerAndroid.startCapture(). | 214   // Delegate this choice to VideoCapturerAndroid.startCapture(). | 
| 215   *best_format = desired; | 215   *best_format = desired; | 
| 216   return true; | 216   return true; | 
| 217 } | 217 } | 
| 218 | 218 | 
| 219 }  // namespace webrtc | 219 }  // namespace webrtc | 
| OLD | NEW | 
|---|