Gun? They are not! These are actually camera. When I was wondering why there is such design exist, this is what wiki says:
Gun cameras are cameras used in military vehicles to help measure tactical effectiveness. These cameras are sometimes triggered by the firing of a weapon, hence the name.
The use of gun cameras first became common in World War II aircraft. Some of this footage survives to this day; it is often the source for stock footage in World War II shows and movies.
The term Guncam may also refer to software that records video game footage, it is often triggered by the firing of a weapon in a way similar to the original guncams of WWII. Some popular examples of this software are Growler Guncam and Java Guncam.