Individual Rights and Audio/Video Recording of public servants

Greetings, Before asking my question i would like to tell you what happened in short. I am in Maharashtra for study purposes. I was travelling on my vehicle with other state no. for which I have paid all the due taxes in Maharashtra. I had other documents as well so i was good to drive around. A traffic constable stopped me and I asked him what traffic rule did i break that you are stopping me for? His reply "We dont need reason, I will bound your vehicle and you meet me in court". Then it escalated from there and when i started to record him he told me it's illegal to record police. I didn't hurl any disrespecting words at any moment and maintained my composure. When i started recording only then he calmed down. Many more things he said but I wont go in details. My question is : What are your main legal rights when stopped by traffic police and what legal actions both serious and non-serious one a private citizen can take against a public servant? Is it illegal to record a public servant discharging his duties at public places? Some advice to handle such situations will be appreciated. Thankyou.