The police can pat down the outside of your clothing for weapons any time you are in their presence if they think you are armed. This is usually done on a routine basis if you are detained or arrested. Police are only allowed to do a limited search, or “pat down” outside of your clothing under these circumstances. Unless they have “reasonable suspicion” or “probable cause” to believe that you have committed a crime, they are not allowed to do a more invasive search such as a strip-search or reaching into a bra or pockets. But with probable cause, the stakes go higher.
It is never okay for a police officer to use a pat down search to touch you inappropriately or to determine your gender. Male officers are allowed to “pat down” a woman. If you feel it is safe to do so, you can request a pat down by an officer of the same sex, but it is only a courtesy if the male officer calls for a female officer to search you. Any touching during the search which feels inappropriate or unduly prolonged should be documented.
This does not sound right. A complaint should be registered with the department and the video saved. See a civil rights lawyer ASAP or the video may be lost.