Commit ae8baec
[camera_platform_interface] [camera] [camera_android] Add NV21 as an image stream format (flutter#3277)
### Note: this is a re-created PR from flutter/plugins#6985
---
This PR adds NV21 as an image stream format for android devices. This is the format required for things like MLKit. Unfortunately a lot of people tend to implement the yuv->nv21 incorrectly in dart, which results in countless issues of users saying the image stream doesn't work, or that mlkit doesn't work.
By allowing the plugin to send NV21 to dart, this will fix all of those yuv conversion issues.
Highlights:
- Added an abstraction around `ImageReader` called `ImageStreamReader` and moved the image stream logic into this class to clean up the `Camera` class. This allows us to test the image stream handler in isolation.
- Added tests for `ImageStreamReader` to make sure it only calls the `removePlaneBufferPadding` function for planes that contain padding.
- Added a new utility class called `ImageStreamReaderUtils` which contains the logic for trimming the padding.
- Added tests for `ImageStreamReaderUtils` to make sure it only removes padding when a given buffer contains padding to be removed.
- There are tests to confirm both that `removePlaneBufferPadding` is only called when padding is present, and to confirm that if `removePlaneBufferPadding` does happen to be called with a buffer containing no padding, it still returns a valid buffer.
*List which issues are fixed by this PR. You must list at least one issue.*
- flutter/flutter#118350
*If you had to change anything in the [flutter/tests] repo, include a link to the migration guide as per the [breaking change policy].*1 parent 09cdab8 commit ae8baec
File tree
4 files changed
+35
-3
lines changed- packages/camera/camera
- lib/src
- test
4 files changed
+35
-3
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
1 | 5 | | |
2 | 6 | | |
3 | 7 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
90 | 90 | | |
91 | 91 | | |
92 | 92 | | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
93 | 96 | | |
94 | 97 | | |
95 | 98 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
7 | | - | |
| 7 | + | |
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
| |||
21 | 21 | | |
22 | 22 | | |
23 | 23 | | |
24 | | - | |
| 24 | + | |
25 | 25 | | |
26 | | - | |
| 26 | + | |
27 | 27 | | |
28 | 28 | | |
29 | 29 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
139 | 139 | | |
140 | 140 | | |
141 | 141 | | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
142 | 166 | | |
143 | 167 | | |
144 | 168 | | |
| |||
162 | 186 | | |
163 | 187 | | |
164 | 188 | | |
| 189 | + | |
165 | 190 | | |
166 | 191 | | |
167 | 192 | | |
| |||
0 commit comments