Android上的V4L2视频捕捉

时间:2014-08-14 17:56:19

标签: android linux android-camera video-capture v4l2

我试图在Samsung Galaxy S3上运行视频捕获示例代码here
起初我在许多VIDIOC操作中遇到了一些错误(例如S_FMTSTREAMON),我可以通过以下方式解决这些错误:

  1. 查看kmsg并跟踪内核驱动程序代码以猜测出错了什么。
  2. 在示例代码中添加缺少的操作或修复某些配置。
    将运行示例代码的kmsg日志与启动本机相机应用程序的代码进行比较有很大帮助..(因为后者我们确信它有效)
  3. 现在我来到这里..所有ioctls都成功完成,但我得到0数据.. v4l2_buffer->bytesused总是0。

    我绝望了所以我在 fimc_v4l2.c fimc_capture.c (FIMC是三星的V4L2驱动程序)的每个功能中添加了printk日志,这是我在使用相机应用时看到的所有内容:(我只是在从STREAMON返回后粘贴了该部分)

      

    @@@ fimc_dqbuf#bytesused = 0 length = 0
      ### fimc_dqbuf_capture start#bytesused = 0 length = 0
      ### fimc_dqbuf_capture #list empty

    fimc_irq_cap [0],fimc0,cnt [0]
    fimc_irq_cap [0] SKIPPED
    fimc_irq_cap [1],fimc0,   cnt [1]

    @@@@ fimc_dqbuf#bytesused = 0 length = 65545
      ### fimc_dqbuf_capture start#bytesused = 0 length = 65545
      ### fimc_dqbuf_capture #list not empty
      ### fimc_dqbuf_capture #length = 65545
      ### fimc_dqbuf_capture end #length = 65545,bytesused = 0


    @@@ fimc_qbuf#bytesused = 0 length = 0
      ### fimc_qbuf_capture start
      ### fimc_qbuf_capture#buf state ok
      ### fimc_qbuf_capture #index = 0
      ### fimc_qbuf_capture结束

    @@@ fimc_dqbuf# bytesused = 3225703951 length = 0
      ### fimc_dqbuf_capture start#bytesused = 3225703951 length = 0
      ### fimc_dqbuf_capture #list empty

    fimc_irq_cap [2],fimc0,cnt [2]

    @@@ fimc_dqbuf#bytesused = 3225703951 length = 65545
      ### fimc_dqbuf_capture start#bytesused = 3225703951 length = 65545
      ### fimc_dqbuf_capture #list not empty
      ### fimc_dqbuf_capture #length = 65545
      ### fimc_dqbuf_capture end #length = 65545,bytesused = 3225703951

    @@@ fimc_qbuf#bytesused = 0 length = 0
      ### fimc_qbuf_capture start
      ### fimc_qbuf_capture#buf state ok
      ### fimc_qbuf_capture #index = 1
      ### fimc_qbuf_capture结束

    ... ...

    我将日志分成块:它基本上是DQBUF(empty) -> IRQ -> DQBUF -> QBUF循环。我用粗体标记b->lenghtb->bytesused首先获得非零值。

    我修改了 v4l2示例代码来模拟这个确切的流程。
    但是你可以看到b->lenghtb->bytesused只有0:

      

    @@@ fimc_dqbuf#bytesused = 0 length = 0
    ### fimc_dqbuf_capture   start#bytesused = 0 length = 0
    ### fimc_dqbuf_capture #list   空的

    fimc_irq_cap [0],fimc0,cnt [0]
    fimc_irq_cap [0]   SKIPPED
    fimc_irq_cap [1],fimc0,cnt [1]

    @@@@ fimc_dqbuf#   bytesused = 0 length = 0
    ### fimc_dqbuf_capture start#   bytesused = 0 length = 0
    ### fimc_dqbuf_capture #list not empty
      ### fimc_dqbuf_capture #length = 0
    ### fimc_dqbuf_capture end#   length = 0,bytesused = 0

    @@@ fimc_qbuf#bytesused = 0   length = 0
    ### fimc_qbuf_capture start
    ### fimc_qbuf_capture#   buf state ok
    ### fimc_qbuf_capture #index = 0
    ###   fimc_qbuf_capture结束


      @@@ fimc_dqbuf# bytesused = 0   length = 0
    ### fimc_dqbuf_capture start#bytesused = 0 length = 0
      ### fimc_dqbuf_capture #list empty

    fimc_irq_cap [2],fimc0,   cnt [2]

    @@@ fimc_dqbuf#bytesused = 0 length = 0
    ###   fimc_dqbuf_capture start#bytesused = 0 length = 0
    ###   fimc_dqbuf_capture #list not empty
    ### fimc_dqbuf_capture#   length = 0
    ### fimc_dqbuf_capture end #length = 0,bytesused = 0
      
    @@@ fimc_qbuf#bytesused = 0 length = 0
    ### fimc_qbuf_capture   start
    ### fimc_qbuf_capture#buf state ok
    ###   fimc_qbuf_capture #index = 1
    ### fimc_qbuf_capture end

    ...

    我已尝试在内核驱动程序源代码中使用 grep 来查找何时可以bytesused分配但无法找到正确的位置。

    有人有想法吗?我非常感激


    修改

    当我在strlen() ped缓冲区的指针上使用mmap时,它实际上返回一个合理的值。返回的尺寸会根据我指向相机的位置而变化(当我用手遮住镜头时,它会变得非常小,当它用来遮住镜头时,它会变得非常小;当它变得明亮时它会变化大约1万;它还会保持不变当我移动相机时改变)。我猜测这表明我实际上得到了帧。
    但我仍然无法弄清楚为什么bytesused始终为0。

0 个答案:

没有答案